Skip to content
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

Parallel request to the server fails #1814

Closed
a6datta opened this issue Dec 13, 2015 · 7 comments
Closed

Parallel request to the server fails #1814

a6datta opened this issue Dec 13, 2015 · 7 comments

Comments

@a6datta
Copy link

a6datta commented Dec 13, 2015

Hi, I am running osrm back end in a windows pc. When I request a route between two points it returns the result almost instantly. However if I use 'async Task' to request routes between two point it fails with the error below

"10.267537576608 14.292158787192 System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time

I am making the request from the c# application like below...
loop start
Task = Task.Factory.StartNew(() => CalculateDistance(start, end));
loop end
await Task.WhenAll();

As dot net executes each task within the loop in separate thread, my understanding is that the requests are being made almost parallel which is causing deadlock in the osrm server.

I tried with only 8-10 request.

Is there any plan to accommodate this capability within back end?

@emiltin
Copy link
Contributor

emiltin commented Dec 14, 2015

node-osrm is the recommended way to run osrm in production: https://github.com/Project-OSRM/node-osrm

@kostadin24
Copy link

I had have the same problem when use many threads - my program stalls and returns same error after 30 seconds waiting for response. It was caused from .Net. For some reasons .net fails with request from many threads.
When finally made simultaneous request from lot of instances of program - on my PC and from other machines in LAN - it works fine.
I didn't try this on other languages, but look at this from wiki docs:

Notably absent is support for pipelining, which allows multiple requests to be served over a single socket. OSRM Issue #531 has some documented workarounds.

@hoerup
Copy link
Contributor

hoerup commented Dec 14, 2015

I agree with @kostadin24 that it must be in a problem with .net or your code. I have no problem issuing 8 simultaneous requests to osrm-routed via threads from a java program.

@perliedman
Copy link

As @kostadin24 says, note that OSRM does not support pipelining. Depending on how you create HTTP connections in .NET, you might be using pipeling by default. Try explicitly settings specifying the KeepAlive property: https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.keepalive(v=vs.110).aspx

@TheMarex
Copy link
Member

@a6datta any updates here?

@a6datta
Copy link
Author

a6datta commented Dec 21, 2015

@TheMarex It was actually an issue with my Windows 8 system itself, not particularly the limitation of dot net framework. I just moved the OSRM backend to a windows server machine and it works fine.

@TheMarex
Copy link
Member

Thanks @a6datta for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants