Websocket does not connect to server

Asked

Viewed 1,840 times

0

I am not able to make the connection with server.

Obs: the browser supports websocket.
I’m doing it this way

var socket = new WebSocket('sw: localhost:8080'); 

Any suggestions?

  • Any error message? if possible post more details.

  • Yes. Firefox says it was not possible to establish the connection and IE reports Websocket Error: Incorrect HTTP Response. Status code 200, OK. I’m using WAMP and Apache is running on port 8080. You think the connection should be directed to a php server?

  • how you set up your socket server ?

  • you should take a look in this plugin

2 answers

2

In a brief reply, you probably forgot the // and you changed the ws for sw, I believe that the right thing should be:

var socket = new WebSocket('ws://localhost:8080');

0

Check the port that is configured on the server for Websocket, the 8080 port is usually used for HTTP and Websocket uses another port. Find the correct port and switch to the Webscoket constructor in javascript.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.