[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

"Address already in use" Error with net/http

Christian Kerth

7/15/2008 2:42:00 PM

Hey!

I'm downloading a large number of files via net/http GET Requests using
5 Threads.

Each Thread does something like this:

req = Net::HTTP::Get.new(url.path)
conn = Net::HTTP.new(url.host, url.port)

res = conn.start {
|http|
http.request(req)
}

While the threads are running i sometimes get the Error WSAEADDRINUSE
10048 "Address already in use" (i have a German version of Windows XP
SP2. There the exact message is: Normalerweise darf jede Socketadresse
(Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet
werden. - connect(2))

It seems like my code makes Windows run empty on available ports for my
requests.

Any solutions?

Thx
--
Posted via http://www.ruby-....

3 Answers

Christian Kerth

7/17/2008 2:10:00 PM

0

> req = Net::HTTP::Get.new(url.path)
> conn = Net::HTTP.new(url.host, url.port)
>
> res = conn.start {
> |http|
> http.request(req)
> }
>
> While the threads are running i sometimes get the Error WSAEADDRINUSE
> 10048 "Address already in use" (i have a German version of Windows XP
> SP2. There the exact message is: Normalerweise darf jede Socketadresse
> (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet
> werden. - connect(2))

if i perform the request like this the error is not thrown:

res = conn.request(req, @data)

I investigated i bit further into ruby's code and found out that if you
don't call start and provide a closure, Net:HTTP.request implicitly
calls start with a closure. But it modifies the req['connection']
parameter before. It sheems like this prevents the error?

def request(req, body = nil, &block) # :yield: +response+
unless started?
start {
req['connection'] ||= 'close'
return request(req, body, &block)
}
end

Robert Dober

7/17/2008 2:29:00 PM

0

On Tue, Jul 15, 2008 at 4:41 PM, Christian Kerth
<christian.kerth@dynamicmedia.at> wrote:
> Hey!
>
> I'm downloading a large number of files via net/http GET Requests using
> 5 Threads.
>
> Each Thread does something like this:
>
> req = Net::HTTP::Get.new(url.path)
> conn = Net::HTTP.new(url.host, url.port)
>
> res = conn.start {
> |http|
> http.request(req)
> }
>
> While the threads are running i sometimes get the Error WSAEADDRINUSE
> 10048 "Address already in use" (i have a German version of Windows XP
> SP2. There the exact message is: Normalerweise darf jede Socketadresse
> (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet
> werden. - connect(2))
>
> It seems like my code makes Windows run empty on available ports for my
> requests.
>
> Any solutions?
Install Linux ;) -at least we could trace this easily, hopefully some
Window's gurus can help here.

Seriously, this is quite strange, seems as if the client tries to use
an opened port. This however is exactly what clients do not do
normally.
I have never had this error unless I was trying to listen on a port
already used (thus being a server), very often because I started the
same webrick program twice :-O.

Looks almost like a bug to me.
Cann you provide more information like the output of netstat?

R.

Christian Kerth

7/18/2008 9:06:00 AM

0

> Cann you provide more information like the output of netstat?
>
> R.

Aktive Verbindungen

Proto Lokale Adresse Remoteadresse Status
TCP esprimo3600:1107 localhost:1108 HERGESTELLT
TCP esprimo3600:1108 localhost:1107 HERGESTELLT
TCP esprimo3600:kpop localhost:1110 HERGESTELLT
TCP esprimo3600:1110 localhost:kpop HERGESTELLT
TCP esprimo3600:3480 localhost:30500 WARTEND
TCP esprimo3600:4269 localhost:12345 HERGESTELLT
TCP esprimo3600:4270 localhost:12345 HERGESTELLT
TCP esprimo3600:4298 localhost:22303 HERGESTELLT
TCP esprimo3600:4299 localhost:30500 HERGESTELLT
TCP esprimo3600:4302 localhost:30500 HERGESTELLT
TCP esprimo3600:4303 localhost:30500 HERGESTELLT
TCP esprimo3600:4305 localhost:30500 HERGESTELLT
TCP esprimo3600:4306 localhost:12345 HERGESTELLT
TCP esprimo3600:4307 localhost:30500 HERGESTELLT
TCP esprimo3600:4309 localhost:30500 HERGESTELLT
TCP esprimo3600:4311 localhost:30500 HERGESTELLT
TCP esprimo3600:4313 localhost:30500 HERGESTELLT
TCP esprimo3600:4318 localhost:12345 HERGESTELLT
TCP esprimo3600:4319 localhost:12345 HERGESTELLT
TCP esprimo3600:4320 localhost:30500 HERGESTELLT
TCP esprimo3600:4321 localhost:30500 HERGESTELLT
TCP esprimo3600:4327 localhost:30500 HERGESTELLT
TCP esprimo3600:4502 localhost:30500 HERGESTELLT
TCP esprimo3600:4546 localhost:30500 HERGESTELLT
TCP esprimo3600:12345 localhost:4269 HERGESTELLT
TCP esprimo3600:12345 localhost:4270 HERGESTELLT
TCP esprimo3600:12345 localhost:4306 HERGESTELLT
TCP esprimo3600:12345 localhost:4318 HERGESTELLT
TCP esprimo3600:12345 localhost:4319 HERGESTELLT
TCP esprimo3600:22303 localhost:4298 HERGESTELLT
TCP esprimo3600:30500 localhost:4299 HERGESTELLT
TCP esprimo3600:30500 localhost:4302 HERGESTELLT
TCP esprimo3600:30500 localhost:4303 HERGESTELLT
TCP esprimo3600:30500 localhost:4305 HERGESTELLT
TCP esprimo3600:30500 localhost:4307 HERGESTELLT
TCP esprimo3600:30500 localhost:4309 HERGESTELLT
TCP esprimo3600:30500 localhost:4311 HERGESTELLT
TCP esprimo3600:30500 localhost:4313 HERGESTELLT
TCP esprimo3600:30500 localhost:4320 HERGESTELLT
TCP esprimo3600:30500 localhost:4321 HERGESTELLT
TCP esprimo3600:30500 localhost:4327 HERGESTELLT
TCP esprimo3600:30500 localhost:4502 HERGESTELLT
TCP esprimo3600:30500 localhost:4546 HERGESTELLT
TCP esprimo3600:1025
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1026
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1027
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1028
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1029
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1030
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1031
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1032
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1033
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1034
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1035
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1036
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1037
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1038
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1039
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1040
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1041
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1042
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1043
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1044
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1045
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1046
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1047
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1048
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1049
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1050
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1051
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1052
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1053
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1054
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1055
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1056
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1057
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1058
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1059
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1060
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1061
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1062
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1063
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1064
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1066 217.28.105.91:http SCHLIESSEN_WARTEN
TCP esprimo3600:1067
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1068
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1069
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1070
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1071
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1072
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1073
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1074
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1075
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1076
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1077
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1078
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1079
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1080
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1081
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1082
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1083
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1084
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1085
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1086
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1087
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1088
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1089
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1090
62.99.231.114.sh.interxion.inode.at:55623 HERGESTELLT
TCP esprimo3600:1091
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1092
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1093
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1094
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1095
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1096
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1097
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1098
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1099
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1100
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1101
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1102
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1103
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1104
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1105
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1106
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1111
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND
TCP esprimo3600:1112
62-99-141-244.c-gmariatrost.xdsl-line.inode.at:8080 WARTEND