New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iOS - HTTP mode - loses connection without error - fiddly fix #691
Comments
We heard of similar occasional problems using MQTT. Both MQTT and HTTP share the same network API NSURLSession, so the problem might be related. Do you use plain HTTP or HTTPS? If HTTPS, which kind of certificates do you use? |
HTTPS, the server I uses, uses Let's Encrypt certificates. Do you think it chokes on there? I do not think so. It is always one or the other phone which stops working, and then the other just keeps on working without needing to interfere. |
I doubt it's the certificates. You say home server, is this actually a server in your home which you address via a dynamic DNS entry, and if so, would it be possible for you to use a different provider? |
Hi, Yes it is via a DDNS entry (ddns.net). You'd think another one won't have the issue? Why is the issue on one phone only and not on both? |
I missed the part with "the other phone". |
np, but what could be the issue then. And why does it not throw errors when it is clearly not getting a correct status from the server? Can I do anything on the server end to return a better status for each access? |
Have you been able to determine, when one of the phones stops publishing, whether there really is nothing arriving at the server? (HTTP server logs)? Also is there any way you could try and track whether, when a phone stops publishing, whether a change in the DDNS name has ocurred? (I am assuming your IP changes occasionally - ignore if that's not the case.) Also, you write I can fix it by changing the HTTP URL to a faulty one. Have you attempted swiping the app out when publishing is not possible, and restarting? Does that solve the issue? And finally, for now, please state iPhone model, iOS version, and we'll assume lastest OwnTracks version. :-) |
Thanks :) |
We have setup a "home server" with dynamic DNS here (also via When the problem occurs, what does the status screen show? If it encounters a problem, it will display the error until it tries to reconnect. The reconnect happens after 1,2,4,8,16,... seconds. |
I will update when the next time occurs. In the status screen no errors will show, it just shows "inactive". Even after force publishing the location. Will be continued. Are you sure no one has encountered this before? I have had it happen numerous times |
Now I get an error on both devices, unrelated or different to the problems I encountered before, but since I finally see an error code I thought to chime in. The error I get now is error HTTP response 500. If I go to the browser, I can perfectly visit the url I have set. This happens since last night on both devices, no certificates or anything has changed in the meantime. |
HTTP status codd 500 is being caused server-side, and you'll have to see in your server logs what the issue is. Maybe some PHP upgrade or other configuration change which might be causing this? |
The app POSTs messages to the URL. A browser typically uses the GET method. |
So after trying a faulty URL and switching it back, I received the request at my server (I have printed out the json request here), but it keeps saying "connecting" until finally getting a timeout 1001 error. All the while it publishes location like below a couple times. batt: 52, So I can confirm server does work and receive the request (again, nothing changed between here and last night). |
That's not JSON ... Be that as it may, I don't think we've yet asked you what softare your OwnTracks devices are actually speaking to. Can you please tell us? |
Raspberry Pi with Espress server |
Do you mean Express (with an 'x'), so a home-grown program based on NodeJS? If so, you're going to have to dig into whatever that code is doing; the HTTP code 500 originates from that. While it might be possible that the server is borking because of some strange data we're giving it, the culprit for the code 500 is on the server side. |
Yes Express sorry. Did you also read I am not getting the 500 error anymore? And do receive the incoming request? |
The thing is, making a POST request from another source does not resolve in a 500 error. The server is up and running and receiving requests. So what HAS changed? |
Lead us through what your Express code does. Which JSON elements it’s expecting in the OwnTracks payload and what it does with the data.
|
Another thing you can do to test is use curl to POST a minimal OwnTracks payload to your server. The following, run on your Raspi should do the trick ( $ curl -v -d ‘{"_type":"location","lat":11,"lon":22}’ http://localhost:pppp It’d help if you could show us the output of that, please. |
|
I was originally using the php endpoint to send a mqtt message locally using, yes, shell_exec. I found out that it i stop using shell_exec, OwnTracks manages to connect without error 500. So stripped the php file, and am now listening with the Express js file to incoming requests, verifying, and then handling the rest. The php file where OwnTracks posts to, is just empty. It works, but owntracks keeps coming up with timeouts 1001 even though it now works. How? Why? |
OwnTracks is watiting for a HTTP response 200. |
I don’t think that curl command was correctly issued in the shell; please pay close attention to the distinct quotes. Regarding your “how”s and “why”s, that’s a good question. I think you are assuming we know what the code you are running looks like, but we do not. I for one do not understand the combination of PHP and Express … So you accepted the HTTP post in PHP and then ran a shell command to produce MQTT? Why? Then you say the php file is “stripped” and Express.js is listening to HTTP. What then, does the php file do? If Express.js is handling your HTTP POST requests, please ensure it responds with an HTTP 200 as @ckrey points out. |
@ckrey: I was giving it a 200 response through php but tried it via express server settings now and that fixes the problem!! @jpmens: at first, I accepted the HTTPS POST in PHP, did some calculations with the data and had it send a MQTT message locally. Why? Because I did not know of any other way to get a MQTT message locally upon outside request. Seems to work fine now, thanks again guys. Although it does not change the fact it is very strange for non-changed code to stop working overnight, and requests to be succesfully made for months in a row and then be stuck. Perhaps it will keep on working now. |
Glad you got it going. |
I have been using OwnTracks for a few years now and it is a great app. I use it to publish my location via http to a home server to track my whereabouts. Ever since I started using the app, every few weeks the connection gets lost. I can fix it by changing the HTTP URL to a faulty one, publish my location, get errors, put back the same URL as there has always been, publish my location et voila: fixed.
This has become a nuissance. Is this a known problem?
The text was updated successfully, but these errors were encountered: