Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reusing HttpConnection

 
Danish Shaukat
Ranch Hand
Posts: 341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi !

Is it possible to create a HttpConnection once, then reuse it multiple times without closing it.

I've tried doing it but I always get an exception: Connection already open.
It seems that you have to create a connection, send/receive data and then close it. Repeat the cycle if you want to communicate with the server again.

Just wanted to now if anyone else has tried doing this.

Danish
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um, but wouldn't each request sent be going to different URL addresses or have different parameters sent. When you do Connector.open(), you pass the URL. So that Connection is pointing to one request getting back one response.

You can set it to Keep-Alive, and maybe that would work, but why is it bad to have to create a Connection when you need it. Because with some providers, they charger per minute of Connection, and if you application keeps it open all the time, then that is charging the user quite a bit of money, which they might not like.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic