I'm running socket.io 1.0 in a node.js app on heroku. I'm talking to my server through an ionic/angular app that I'm running locally on http://localhost:9107
In my app I'm loading socket.io in the front end like this:
<script src="https://myapp.herokuapp.com/socket.io/socket.io.js"></script>
This loads up fine, but then my app starts throwing errors in the console:
https://myapp.herokuapp.com:9107/socket.io/?EIO=3&transport=polling&t=1413741961075-13 net::ERR_CONNECTION_REFUSED
Notice the port number 9107 I'm using to run my ionic app locally in the browser being used in the socket request later on. I have no clue why socket.io is doing this or how I can get rid of that port in there.
Does anyone know why this happens and how to solve this?
This took me a while to figure out but the solution was simple: I manually added the port :443 to my socket connection and that seems to override the behaviour mentioned above!
You don't need to set a port on socket.io client, just use your heroku app url on socketio connection.
Related
i'm trying to create a realtime app with laravel-websockets package, i followed the steps in laravel documents and also the laravel-websockets package and i did all the thing exact the same as docs, but whenever i try to send an event through the channel i receive this error in the browser console:
Firefox can’t establish a connection to the server at wss://127.0.0.1/app/myKey?protocol=7&client=js&version=6.0.3&flash=false.
does any body know how can i solve this error?
i found a solution for my case here:
https://github.com/beyondcode/laravel-websockets/issues/382#issuecomment-631569344
try this out, i hope it works for you too.
I think this is an SSL related problem. Here you are using wss:// protocol on the localhost. I would suggest you use ws:// protocol instead of wss://.
Hope that this will work.
This is more of a network question , I believe. Not sure what the issue is. I have a chat application which uses faye and it runs fine on my system(rails app)
with localhost:3000 having faye mounted on it.I recently deployed this rails app onto bluehost server and when I try to use the faye client on browser ,its giving me this error:
WebSocket connection to 'ws://chat.xyz.com/faye' failed: Error during WebSocket handshake: Unexpected response code: 500
The below requests\handshakes keep on repeating.
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp3
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp4
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp5
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp6
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp7
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp8
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ing%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp9
GET ...chat.xyz.com/faye?message=%5B%7B%22channel%22%3A%22%2Fmet…ng%22%5D%2C%22id%22%3A%221%22%2C%22ext%22%3A%7B%7D%7D%5D&jsonp=jsonp10
And the failed handshakes\requests keep on getting repeated. Seeing the same on server logs also(except the 500 message obviously). The logs dont give any error apart from these repeats
Is it because of proxy\firewall issue. I recently came across an article :
http://www.infoq.com/articles/Web-Sockets-Proxy-Servers
I am not sure whether its related to blocking of requests by proxy servers.
Tried switching to secure protcol. https. Didn't help.
I use a simple client like this:
var client = new Faye.Client('http://chat.xyz.com/faye');
Any help would be great.
I am trying to deploy my dart application on heroku but even when i have got my stream server running in the dyno, i don't have any idea as to how can i get the port number on client side code to connect to the server via websocket. Since i cannot use Platform.environment['PORT'], i don't know how to get the port.
My client side websocket address is this:
var port = '<The port number i need>';
var url = 'ws://0.0.0.0:$port/ws';
It has taken a lot of effort to deploy successfully to heroku. Please tell me that there is a way to make this work.
I haven't used Heroku myself yet but here the doc says
The Heroku platform automatically routes HTTP requests sent to your app’s > hostname(s) to your web dynos. The entry point for all applications on >the Cedar stack is the herokuapp.com domain which offers a direct routing path to your web dynos.
It should be possible to make a HTTP request to the hostname of your web dyno to connect to your server and your server should be able to do the Platform.environment['PORT'] and report the result back.
Referring to the link given by Gunter Why won't my app establish websocket connection on Heroku?, it just happens to be that the client side doesn't require an actual port to connect.
Doing the window.location.origin and replacing http:// with ws:// did the trick! Although problem is that even when my database opens up and all, there's some problem when using objectory to query upon it.
You can try " heroku run bash " and run your server in terminal then you can easily find your port in which your app is running.
I'm having a bizarre issue. I'm running Sails 0.9.7 and locally everything works great. Deployed on Heroku, everything works great except while I'm at work. At work, the pages work fine, but Sockets is getting 503ed:
WebSocket connection to 'ws://gameshowhub.herokuapp.com/socket.io/1/websocket/usGTFi4hOfyza-B4LN8d' failed: Error during WebSocket handshake: Unexpected response code: 503
Everywhere else I go (geographically) the page seems to work, so I think my work network is blocking the Sockets port. Does that sound right? Where can I change the socket's port in Sails - I can't seem to find it anywhere...
sails sockets will use the default port: sails.config.port this will be 1337 if you didn't change it.
Heroku doesn't support websockets out of the box. You'll need to enable them via:
heroku labs:enable websockets
More info at devcenter.heroku.com/articles/node-websockets.
If websockets will get blocked via firewall they should switch to
htmlfile
xhr-polling
jsonp-polling
you may also enable flashsockets in the config/sockets.js-file.
I wanna create a connection between my mobile Safari and nodejs + socket.io on my Macbook.
When i call localhost:8080 from my laptop, everything works fine. The console says that the client is connected and my little website is displayed.
When i call it over my mobile browser with 10.0.1.5:8080, the website is displayed as well, but my socket.io don't identify the mobile browser (iPhone) as client and nothing happens on the console board.
Does anybody where the problem is?
I found this post on SO, probably can help you out. why does my nodejs socket.io app not work on ios6
Localhost is local to the machine. You're IP should use a ip address
or domain name:
something like: io.connect('192.168.1.110'); or
io.connect('test.myapp.com');
WebSockets do not work over cellular network as they are not forwarded by the http proxy.
A possible workaround it to set the WebSocket server port to 443 (https) which forwards everything (as https is encrypted the proxy has to forward it in order to support https).
To see a real world example which solves this problem this way checkout nearby.
Remember this requires using two http servers:
Serving you mobile application (on port 80)
Serving the web sockets on (port 443)
Else you always have to use the specific ports in your urls which is mostly not preferred in production.