4

I am using a server to send some piece of information to another server every second. The problem is that the other server response is few kilobytes and this consumes the bandwidth on the first server ( about 2 GB in an hour ). I would like to send the request and ignore the return ( not even receive it to save bandwidth ) ..
I use a small python script for this task using (urllib). I don't mind using any other tool or even any other language if this is going to make the request only.

Awkens
  • 41
  • 2
  • You'll have to either make the server not send a response, or use UDP or something. – Falmarri Feb 19 '11 at 06:23
  • 1
    One request per second and 5k per response is 18 MB/hour, which is orders of magnitude lower than 2 GB. – Glenn Maynard Feb 19 '11 at 07:18
  • You could ignore the response, but by the time it gets to your first server so it can ignore it, the bandwidth has already been used. – Karl Bielefeldt Feb 19 '11 at 07:45
  • I use a lot of threads for that so I have a huge amount of data coming and actually consuming the first server network speed completely. – Awkens Feb 19 '11 at 08:57
  • Surely you would just set a rule on the router to ignore specific traffic. Do packet inspection and drop what looks like a reply from that addr. Also threads? *vomit* – Jakob Bowyer Feb 19 '11 at 10:22

3 Answers3

2

A 5K reply is small stuff and is probably below the standard TCP window size of your OS. This means that even if you close your network connection just after sending the request and checking just the very first bytes of the reply (to be sure that request has been really received) probably the server already sent you the whole answer and the packets are already on the wire or on your computer.

If you cannot control (i.e. trim down) what is the server reply for your notification the only alternative I can think to is to add another server on the remote machine waiting for a simple command and doing the real request locally and just sending back to you the result code. This can be done very easily may be even just with bash/perl/python using for example netcat/wget locally.

By the way there is something strange in your math as Glenn Maynard correctly wrote in a comment.

6502
  • 112,025
  • 15
  • 165
  • 265
2

For HTTP, you can send a HEAD request instead of GET or POST:

import urllib2

request = urllib2.Request('https://stackoverflow.com/q/5049244/')
request.get_method = lambda: 'HEAD' # override get_method
response = urllib2.urlopen(request) # make request
print response.code, response.url

Output

200 https://stackoverflow.com/questions/5049244/how-can-i-ignore-server-response-t
o-save-bandwidth

See How do you send a HEAD HTTP request in Python?

Community
  • 1
  • 1
John La Rooy
  • 295,403
  • 53
  • 369
  • 502
  • I know the head option, but in my case, the server would return a 405 method not allowed if I send the HEAD method – ospider Aug 18 '17 at 03:55
1

Sorry but this does not make much sense and is likely a violation of the HTTP protocol. I consider such an idea as weird and broken-by-design. Either make the remote server shut up or configure your application or whatever is running on the remote server on a different protocol level using a smarter protocol with less bandwidth usage. Everything else is hard being considered as nonsense.