Error: Unexpected server response: 503 Service Unavailable

victorang17 months ago

Im trying to connect to the traccar websocket,
i have already get the session id with api/session with sample url like this http://domain:82/api/session and get the JSESSIONID.

After that im using postman to connect to the traccar websocket like this
url: ws://domain:82/api/socket
headers ->
Cookie: {JSESSIONID value get from api/session}

The postman giving Error: Unexpected server response: 503 this error.

What am i doing wrong? Thanks

Anton Tananaev7 months ago

Have you compared your request with the official app?

victorang17 months ago

I have tried to duplicate the code of traccar-manager-android with native android but still get the 503

victorang17 months ago

Here is my code (I removed the map, cause i haven't made the API_KEY yet, but in the app we can check either the connection to WS was succeed or failed)
https://github.com/victorang1/traccar-sample

for privacy issue i have changed the DEFAULT_SERVER back to demo url thanks, please help to check @Anton. Thanks a lot

Anton Tananaev7 months ago

Checking your code is beyond what I can do here on the forum.

victorang17 months ago

Okay then i have several questions

  • Does the base url for websocket same with the URL that we used to login to the traccar dashboard?
  • Do i only need to add "Cookie" header when hitting /api/socket?
  • Do we have to enable something to make the websocket server work?
Anton Tananaev7 months ago
  1. Yes.
  2. Yes.
  3. No.
victorang17 months ago

Ok i have solved the issue thanks

Anton Tananaev7 months ago

What was the issue?

victorang17 months ago

Should have sent the Cookie Header like this JSESSIONID={SESSION_ID}