Sending Updates from Device to Server Via Websocket

mjmgoocha year ago

I've successfully connected to the websocket of my Traccar server (I am testing in Postman). I want to Websockets to enable tracking of the device i.e send positional updates from the tracked device to the server, I am not looking to consume data from the websocket.

I am attempting to send the below payload to the server to update the device status, but I'm receiving this error: "1011 Server Error: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asBoolean()" because the return value of "com.fasterxml.jackson.data" which closes the websocket connection.

{
    "devices": [
        {
            "id": 123456,
            "name": "Device1",
            "uniqueId": "123456",
            "status": "online",
            "lastUpdate": "2024-05-30T19:29:47.000Z",
            "positionId": 1,
            "disabled": 0
        }
    ]
}

Questions:

  • Am I using websockets correctly to push data from the tracked device to the server or should I be using the REST API to send updates about device position/status etc?
  • If I am using websockets correctly, is there anything I am missing when sending this payload? (I have attempted to change the values from true/false/1/0 to try and resolve the boolean issue.

Any help is appreciated.

Track-tracea year ago

When you get it working it will be great if you explain it here in detail (with images) how you do sent that devicedata to the server with postman.

mjmgoocha year ago

@Track-trace. It's quite simple! You can change the request type from HTTP to WebSocket in Postman by adding a new connection and clicking on the 'HTTP' icon and then selecting 'WebSocket" to change its type. Then enter your server URL and assign the cookie in the headers like so Cookie: JSESSIONID=node01yourcookiesyy6cc1em39.node0. I am manually assigigning the cookie value by making a get request to the sessions endpoint to generate it then simply copy and pasting the value into the Cookie header in the WebSocket Request as I am just testing. Here's the screenshots:

Screenshot 2024-05-31 at 11.05.19.png
Screenshot 2024-05-31 at 11.05.03.png

Anton Tananaeva year ago

We don't support pushing any data via WebSocket. You can only receive updates via it.

mjmgoocha year ago

Thanks Anton. That's great to know.