Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
react-native-reconnecting-websocket
Advanced tools
React native auto reconnect websocket extends WebSocketModule. API design referenced reconnecting-websocket.
It is API compatible, so when you have:
var ws = new WebSocket('ws://....');
you can replace with:
var ws = new ReconnectingWebSocket('ws://....');
Less code, more exponential.
var socket = new ReconnectingWebSocket(url, protocols, options);
url
protocols
options
Options can either be passed as the 3rd parameter upon instantiation or set directly on the object after instantiation:
var socket = new ReconnectingWebSocket(url, null, {reconnectInterval: 3000});
reconnectInterval
integer
1000
maxReconnectInterval
integer
30000
reconnectDecay
integer
or float
1.5
timeoutInterval
integer
2000
maxReconnectAttempts
integer
or null
.null
See the detail in react-native/WebSocket.js
ws = new WebSocketJs("ws://...");
ws.onopen = (e) => {
console.log("onopen",e)
};
ws.onmessage = (evt) => {
console.log("onmessage",JSON.parse(evt.data))
};
ws.onclose = (e) => {
console.log("onclose",e)
};
ws.onerror = (e) => {
console.log("onerror",e)
};
ws.onopen = (e) => {
// execute immediately!
ws.send("heartbeat string");
heartCheck.reset().start()
};
ws.onmessage = (evt) => {
heartCheck.reset().start()
};
var heartCheck = {
timeout: 10000,//default 10s
timeoutObj: null,
serverTimeoutObj: null,
reset:function(){
clearTimeout(this.timeoutObj);
clearTimeout(this.serverTimeoutObj);
return this;
},
start:function(){
let self = this;
this.timeoutObj = setTimeout(function(){
ws.send("heartbeat string");
self.serverTimeoutObj = setTimeout(function(){
ws.close();
}, self.timeout)
}, this.timeout)
}
}
FAQs
websocket module
The npm package react-native-reconnecting-websocket receives a total of 187 weekly downloads. As such, react-native-reconnecting-websocket popularity was classified as not popular.
We found that react-native-reconnecting-websocket demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.