electron: timeout issue in node modules
I’m trying to use socket.io-client from electron v0.27.1, but connecting to the server does not work like expected.
main.js - my electron app client.js - client without electron, this works server.js
- running
main.jswithelectron path/to/my/appwhileserver.jsis running, I get timeouts - if I put the call to
initSocket()inmain.jsbeforeapp.on(ready", ...)it successfully connects but I have to wait like 25 seconds before it happens - running
client.jswith io.jsv1.6.3works like a charm (even with the same socket.io options as inmain.js)
Any idea what’s happening?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 2
- Comments: 20 (5 by maintainers)
What does closed due to abandonment mean? Abandoned by whom? I think a lot of people would still consider this an issue…
I’ve finally done it, it seems like a problem with XHR / JSONP polling transport. I am using
electron 1.0.2andsocket.io 1.4.6Just specify in your client when setting the connection that you only want to use websockets.
var socket = require('socket.io-client')('http://localhost:5000', { transports: [ "websocket" ] });Hope this helps
I am also affected by this (Ubuntu 15.10, electron-prebuilt 1.2.8, socket.io-client 1.4.8). I had the same experience as @andresmeidla, forcing websocket transport didn’t fix it in the end. Thanks to @darky! Switching from “localhost” to the ip seems to work for now, at least for testing locally.
Forcing it to use websockets as transport doesn’t seem to be a solution (at least for me). I tried it a couple of days ago, and it seemed to work fine at first - client connected right away, messages got delivered etc. But the error returned after some time (couple of hours and lots of connecting/disconnecting, appliance restarts). So my guess is that all it did is change some internal timing so that it happened to succeed at first.