New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

websocket-heartbeat-js

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

websocket-heartbeat-js

websocket heartbeat

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.9K
decreased by-8.44%
Maintainers
1
Weekly downloads
 
Created
Source

websocket-heartbeat-js

文档未完待续,如需使用,请看demo代码,预览demo show


介绍

websocket-heartbeat-js基于浏览器js原生websocket封装,主要目的是保障客户端websocket与服务端连接状态。该程序有心跳检测及自动重连机制,当网络问题或者后端服务问题造成客户端websocket断开,程序会自动尝试重新连接直到再次连接成功。

用法

install

npm install websocket-heartbeat-js

import

import WebsocketHeartbeatJs from 'websocket-heartbeat-js';
let wsHeartbeat = new WebsocketHeartbeatJs({
    url: 'ws://xxxxxxx'
});

script tag

配置options

new WebsocketHeartbeatJs(options);
Object
    url: 'ws://xxxx',           //must
    pingTimeout: 15000,         //default
    pongTimeout: 10000,         //default
    reconnectTimeout: 2000,     //default
    heartMsg: "HeartBeat"       //default

hook function

onclose
onerror
onopen
onmessage
onreconnect

demo

demo show

blog

初探和实现websocket心跳重连

Keywords

FAQs

Package last updated on 07 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc