-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling "connection error" #21
Comments
Try to use |
Still hangs forever on node.js 12. It never throws.. You can reproduce this way: import ws from 'isomorphic-ws'
import simpleDDP from 'simpleddp'
const opts = {
endpoint: 'wss://google.com',
SocketConstructor: ws,
reconnectInterval: 500,
};
DDP = new simpleDDP(opts, [simpleDDPLogin]);
;(async () =>{
try {
console.log("will hang")
await DDP.connect()
console.log("this never gets logged!")
} catch(error) {
console.log("this never happens too", error)
}
console.log("executed 2")
})() On the Chrome browser, I get a console.error that comes from socket.js to the console but it doesn't throw / get caught as well: Does it |
The error happens earlier because by default simpleDDP will try to connect to the endpoint and you are not putting const opts = {
endpoint: 'wss://google.com',
SocketConstructor: ws,
reconnectInterval: 500,
autoConnect: false
}; Have a look here about all the constructor parameters https://gregivy.github.io/simpleddp/simpleDDP.html, there is also |
Concerning the |
Also don't forget that you have these events: server.on('connected', () => {
// do something
});
server.on('disconnected', () => {
// for example show alert to user
});
server.on('error', (e) => {
// global errors from server
}); |
Currently when the webserver is down for maintenance i get the following error on my Browser console.
socket.js:64 WebSocket connection to 'ws://[...]/websocket' failed: Error during WebSocket handshake: Unexpected response code: 503
Is that a way of gracefully handling connection errors so they don't end up in the Browser Console and the application can deal with them programmatically, for instance showing an UI element.
The text was updated successfully, but these errors were encountered: