Seconds removed from api in version 3.3?

ajswe9 years ago

I just upgraded from 3.1 to 3.3 and everything seems to work fine. The only problem I have is that the api to get positions now returns times without seconds for some reason.

For example:
"....serverTime":"2015-10-26T07:23Z","deviceTime":"2015-10-26T07:23Z","fixTime":"2015-10-26T07:23Z...."

Anyone else having this problem, or knows how to fix it?
I really need to get the seconds, and I have checked that they exist in the database.

Anton Tananaev9 years ago

It's a known issue that's already fixed in the code base. Please try following build:

https://www.dropbox.com/s/cgmlansv32j3ii0/tracker-server.jar?dl=0

ajswe9 years ago

Ok, thanks, I will try the build later today.

ajswe9 years ago

The build works fine.

The only thing that I cannot get to work is the new web socket call. Is it possible that you could give me an example how to do such call using javascript?

(I get "Error during handshake. Unexpected response code: 405" when I try)

Anton Tananaev9 years ago

You can find JavaScript example of WebSocket call here:

https://github.com/tananaev/traccar/blob/master/web/app/controller/Root.js#L89

ajswe9 years ago

I did just like that, except that the client is not located on the same server as the server so I hade to change the host adress.

Is there some authentication that I am missing?

Anton Tananaev9 years ago

Not sure what you mean by that. For authentication server uses session cookie, so you need to login first.

ajswe9 years ago

Ok, that is what I am missing then. I am just not sure how to make the login call and how to set the cookie before the socket call. I will play around a bit to see if I can get it working, but if there is a simple example it would help a lot.
I am not used to Extjs so the code example previous is a bit hard for me to understand.

Anton Tananaev9 years ago

If you are using JavaScript in browser to make calls, you don't need to worry about cookies. Browser will take care of everything automatically. You just need to create a session using POST request to "/api/session" with email and password parameters before creating a WebSocket connection.

ajswe9 years ago

Perfect, thanks!

ajswe9 years ago

The login request works fine and I can see that the cookie has been set in the browser. However, the socket request still gives me the same error: "failed: Error during WebSocket handshake: Unexpected response code: 405".

Anton Tananaev9 years ago

Can I see your JavaScript code for WebSocket connection?

ajswe9 years ago

var protocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
var host = "//www.mytraccarhost.com";
var socket = new WebSocket(protocol + host + '/api/socket');

socket.onmessage = function (event) {
console.log("Data: " + event.data);
}

socket.onclose = function (event) {
console.log("code: " + event.code);
console.log("reason: " + event.reason);
};

Console output:
code: 1006
reason:

Anton Tananaev9 years ago

Are you sure it's the same host as you do the session API call on? If the host is different, it won't get same session cookies.

ajswe9 years ago

Yes, it is the same host.

Note that the client and server is located on different domains. And right now I am trying the client from a local dev envrinonment so the origin host is "localhost".