Websocket connection

Paul Martinez4 years ago

Is there an example of a websocket connection with javascript?
I have checked the forum and I have not found it ...

Anton Tananaev4 years ago

Have you checked examples that we provide in the repo?

https://github.com/traccar/traccar-web/blob/master/web/simple/app.js

Paul Martinez4 years ago

I've been testing the example and it throws me these errors in the browser console:

  1. GET http://xxx.xxx.xxx.xxx:8082/api/session?token=undefined 404 (Not Found)

  2. Uncaught SyntaxError: Unexpected token H in JSON at position 0

I think that the token is obtained once you log in correctly, but in the example code it nowhere appears where one can set the session credentials.

Please if you could guide me ...

Anton Tananaev4 years ago

I would recommend you read and understand what the code does. It should answer your questions.