Error: Unexpected server response: 503 Service Unavailable

victorang1a year 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 Tananaeva year ago

Have you compared your request with the official app?

victorang1a year ago

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

victorang1a year 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 Tananaeva year ago

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

victorang1a year 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 Tananaeva year ago
  1. Yes.
  2. Yes.
  3. No.
victorang1a year ago

Ok i have solved the issue thanks

Anton Tananaeva year ago

What was the issue?

victorang1a year ago

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