Can not connect web socket with javascript

Question:

I want to connect to my web socket that put on amazone instance with some ip. I can connect my web socket with some ip and port with google rest client app and its working very well.
Screen Shot :
enter image description here

But if i want to connect this with java script it can not connect. This is working fine before 2-3 month. i have not change and thing but its not working now.
If i want to connect with firefox it produce an error.
Here is my code :-

This is alerting status 0 and error show in console :-

Answer:

I’d try your code and for me is working just fine, I’d test it with this webpage: https://www.websocket.org/echo.html , maybe could be helpful for testing purposes. But also i found this question: websocket-rails, websocket handshake error , maybe also help.
However i’d just change the host in your code to this:”ws://echo.websocket.org”, and everything works without problems.
Hope you find a solution and that this info was of any help. Here’s your code that i used for the test:

*Sorry for my bad english.

Leave a Reply