Question

I want to send data over to my server via HTTP GET requests, every 1-2 seconds.

Should I create a new connection every time, or should i keep the connection open and keep sending requests over the same connection? If I employ the latter method would httplib keep the connection alive, what happens if the connection is broken?

I am not very familiar with http and networking protocols.

EDIT: I am working on gps tracking system for my university project, I need to regularly upload the coordinates to a database via php script.

Was it helpful?

Solution

The thing to remember about an HTTP connection is it's still, at a lower level, a socket connection over TCP. They can be prone to issues with leaving a connection open, even if you're constantly streaming data from the source.

While some pretty serious efforts have been made in this area (socket.io, websockets, HTTP long polling, etc), your best and simplest bet is to just make new requests every couple of seconds.

However, there are specific use cases for using things like websockets, so perhaps you can explain what you're doing a little better, then maybe we can say for sure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top