• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending a http-request without waiting for response

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I am sending http-requests to a webservice but am not interested in the response.

So I used the URL.openConnection()-Method, opened an OutputStream wrapped by an OutputStreamWriter and sent the request. But even flushing and closing this Writer does not result in the request to be actually processed by the service. I have access to the logfile of this service so I can see that the service receives this request (or starts to log and process it) not until I use the Connection.getInputStream()-method. Of course this results in my program waiting until the service has done a lot of processing and written the response. But this takes quite a long time and I don't need the response. (Creating a new Thread to send the request and wait is unfortunately not an option)

Anyone an idea where exactly the problem lies?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sasha Ruehmkorf:

Anyone an idea where exactly the problem lies?



You are not using HTTP correctly. HTTP is a request-response protocol. By not reading the response you are not fulfilling the protocol and the server is (correctly) ignoring your request.
 
Sasha Ruehmkorf
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's exactly the answer I feared the most ;-)

Thanks for your quick reply!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic