Communication between browser and pi fails intermittently on Safari

Realise, this was already raised as a bug https://github.com/BrewPi/brewpi-www/issues/42 but i just wonder whether anyone is looking into this?

I predominantly use my iPhone to make adjustments via the webgui and generally use Safari because of continuity, so it would be nice if this could be resolved.

I’ve been scouring the web to see if anyone has reported similar issues with other python script apps but can’t see anything, but to be honest i don’t know what i’m looking for or anything about python, but i had a bash anyway.

I’ve managed to isolate the LCD display in a separate webpage and the same error occurs see here so i guess that means it has something to do with jquery-1.11.0.min.js

so a quick google and - http://blog.jquery.com/category/jquery/ suggests it happened around iOS 8 which i think wbarber mentioned in another forum.

So i just swapped out all the 1.11.0 files to 1.11.3.min.js and change the html file to point there. and that didn’t make a difference.

So what else can i look for that might help or are there references elsewhere that i also need to change?

I know in the scheme of things this isn’t a priority but it would be nice to get this sorted.

Thanks Mik

I have tried to investigate this myself.

I got errors on IE10 too: this one in the console:

XMLHttpRequest: Network Error 0x2ef3, Could not complete the operation due to error 00002ef3.

Google told me this was because the content type was interpreted incorrectly, so I changed the jQuery POST to AJAX calls:

This made the error go away IE, but still on some instances of Safari, the AJAX calls were still intermittent.

The bug was not present with:

  • browser: Chrome on Windows
  • browser: IE10 on Windows
  • browser: Safari 8 on OSX10.10.4, webhost: WAMP on Windows
  • browser: Safari 8 on OSX10.10.4, webhost: apache raspberry pi (default)
  • browser: iPad IOS8.1.3, webhost: WAMP on Windows

The bug was present on:

  • browser: iPad IOS8.1.3, webhost: apache raspberry pi (default)

Only with that combo, the AJAX call for the LCD text would fail every other request.

To investigate further, I installed Fiddler. Awesome tool I just found that shows you all network traffic for a process, and easily let’s you inspect the AJAX calls. Easier to use than the built-in (F12) inspector in the browser.

Now for the real kicker:
To snoop on the iOS network traffic, you can route it through fiddler by configuring it as your proxy on iOS:

So I now had this configuration:

iPad --> Fiddler proxy on Windows --> Raspberry Pi

I can see all the AJAX calls the iPad makes in Fiddler now, but suddenly it works: no failed AJAX calls. So for some reason, routing the AJAX calls through the proxy fixes the issue.

Adding cache: false to the AJAX request does not help. Apparently older versions of Safari cached post requests, which could cause some issues.

The apache error logs on the pi show no errors, but the access log only shows a request every 10 seconds, while the interval is 5.

The WAMP access log show a request every 5 seconds.

So it looks Safari is caching POST requests (which is against the standard) but it depends on the webserver. I hope someone can figure it out, because I am stuck!

1 Like

This is in apache.conf on the Raspberry Pi:

KeepAliveTimeout 5

5 seconds, exactly the same as our refresh interval. Setting it to 100 helped with the error on IE.
Will test with Safari later today.

Confirmed! Changing the setting in the apache config fixes the connection issues in Safari!

In /etc/apache2/apache2.conf, if you change the KeepAliveTimeout from 5 to 99, the problem goes away.

KeepAliveTimeout 99

Now what would be the best way to handle this in our install/update script?

I’ll try this when I get home later today and fingers crossed I’ll have similar results!!! Cheers

Excellent this works does require and RPI reboot though, or atleast mine did! Thanks for sorting this

or you could just restart apache ;):

sudo service restart apache2
1 Like

I’m just seeing this error for the first time. I’ve been running with my setup for a few years, never updated it since the original install and noticed that some of the temp settings for room, fridge and beer were missing intermittently on the LCD. I then viewed via my browser and can see that the temps are randomly missing and the beer fermenting is no longer able to maintain the profile temps. I switched to Fridge Constant but it can’t maintain the temp either.

I looked in /var/www/data/beername/beer-2015-09-04-3.json and see the following:

{“c”:[{“v”:“Date(2015,8,4,23,47,36)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,45)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,45)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,45)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,51,46)”},{“v”:18.5},null,null,null,{“v”:21.0},null,{“v”:“16.0”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,53,48)”},{“v”:18.49},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“16.0”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,53,48)”},{“v”:18.49},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“16.0”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,53,48)”},{“v”:18.49},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“16.0”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,55,49)”},{“v”:18.48},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“15.94”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,55,49)”},{“v”:18.48},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“15.94”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,57,50)”},{“v”:18.46},null,null,null,{“v”:21.0},null,{“v”:“15.94”},{“v”:“0”}]},
{“c”:[{“v”:“Date(2015,8,4,23,59,51)”},{“v”:18.45},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“15.94”},{“v”:“6”}]},
{“c”:[{“v”:“Date(2015,8,4,23,59,51)”},{“v”:18.45},null,null,{“v”:16.81},{“v”:21.0},null,{“v”:“15.94”},{“v”:“6”}]}]}

I changed the setting in apache2.conf to 99 but it hasn’t made a difference

Confirming change to timeout to 99 fixed it for me on iPhone6 running iOS 8.1.3(12b466). Thanks Elco.

I think you are responding with a problem that is unrelated to the discussion here.

Please upgrade to the latest version first. If you still have this problem, most likely one if the sensors is bad or the wiring.

yes, sorry. I started following the discussion

http://forum.brewpi.com/discussion/719/resolved-intermittent-cannot-receive-lcd-text-from-python-script-inconsistent-state-of-devices

which was what I was seeing on the LCD “Cannot receive LCD text from Python Script”. That led to the bug report https://github.com/BrewPi/brewpi-www/issues/42 which led to this discussion.
I take your point though and have started to check the wiring and updating the pi and arduino.

I am trying to change the KeepAlive and when I save it tells me that “cant open file to write” How do I fix this so that I can change the time to 5 to 99.

Try opening it with sudo.

1 Like

Thanks @Elco I got fixed and I’m good to go.

Hi i have the same problem every 5 sec. but can not access the file you mentioned. What to do? Not a programming expert

Is
sudo nano /etc/apache2/apache2.conf
not working?

Sorry typo fail, but The Strange thing is that the script is running fine on Chrome on my imac and android, but the script clitch is on Chrome on my ipad every 5 sec

Update, did the keepalive change to 99 and it seems that it has worked on my ipad with Chrome browser

I am using an iPhone 6 with Safari, Chrome, and Firefox. I was experiencing the intermittent LCD issue so I updated the KeepAliveTimeout to 99. Now the LCD issue is persistent. I can’t connect to the web interface with any of my browsers. After putting it back to 5, same thing. What am I doing wrong?

I had to reboot my RPI as the sudo service restart apache2 command didn’t work, did you restart?