Error during WebSocket handshake Unexpected response code: 503

Josue3 years ago

Hello, good morning, I am connecting locally and also try from a different IP of the traccar server, to the Traccar socket. In Google Chrome it returns the problem Error during WebSocket handshake: Unexpected response code: 503, but in other browsers they connect.
Has anyone had the same problem?
Have they solved it?

Anton Tananaev3 years ago

Are you sure you don't have any proxy in between?

Josue3 years ago

Yes, I already checked and I have not, even with a new installation of Google Chrome, the problem persists.
The only way that the socket works for me in chrome is that it is opening the socket in the same url or ip where it connects.

Anton Tananaev3 years ago

Not sure I understand what you mean by this

opening the socket in the same url or ip where it connects

Josue3 years ago

Example:
I am opening the socket from a server with ip
200.200.200.100 and the trobapp application is on the same IP 200.200.200.100 and opens

But if I connect from localhost or from 200.100.24.100 to the ip 200.200.200.100 and it doesn't open, it returns error 503.

Anton Tananaev3 years ago

Then you have some network issues. It has nothing to do with Traccar.

Josue3 years ago

Ok thanks

Ivan Mudryj3 years ago

Same error here.... I need to figure out what network configuration could be wrong....
Error during WebSocket handshake: Unexpected response code: 503

Anton Tananaev3 years ago

Are you using HTTPS?

Josue3 years ago

The only way I could execute the socket correctly in chrome was that the file that opens the connection was on the same server. That is, if I have traccar installed on the IP 200.20.20.1
The code that opens the socket must be on the same server and open the browser on that IP.

Anton Tananaev3 years ago

That likely means you have some network issues.

Ivan Mudryj3 years ago

Finally could connect setting custom Host and Origin headers.
I'm not using https. I need to connect my traccar socket in order to send it the positions information that I get from a client via ftp file.

websocket = new WebSocket("ws://myTraccarServer:8080/api/socket", "", oCookie, oHeaders);
  • being oCookie and oHeaders both List<KeyValuePair<string, string>>
  • and WebSocket a WebSocket4Net

I'm finally connected! Now I have to work on sending messages waiting for traccar to receive and store them.... let's see what happens....