Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detect client disconnects

 
Daniel Estevez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know when a client disconnect before get an http response.

In Tomcat for example I write on the outputstream and then make a flush, this throw an Exception that I can catch. On Websphere thi doesn't happened.

Please help, I search on docs, google and nothing...

Thank you very much!
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Estevez wrote:I want to know when a client disconnect before get an http response.


Why?
 
Daniel Estevez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry my English... is before SEND a response.

Because I need to rollback transactions in a RESTfull service if the client doesn't get a response.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't tell reliably whether a client gets a response over TCP/IP and HTTP. When you send a response it goes into a buffer, from which it gets broken up into packets which are sent individually to the client and reconstructed into the response there.

In your old system you were only catching the case where the client disconnected before you flushed the output stream. There is still plenty of time after that for the client to disconnect, and you weren't catching those cases. If you need transactional reliability then TCP/IP and HTTP aren't the right tools.
 
Daniel Estevez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was thinking that...

Thank you very much Paul!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic