Administrator
|
When using WebClient, "WebClient httpGet: 'http://google.com'" succeeded, but "WebClient httpGet: '<a href="http://localhost:8090'">http://localhost:8090'" reported "ConnectionTimedOut: Cannot connect to 127.0.0.1:8090"
The address looked fine from Safari. What gives? Thanks. Sean Log: ConnectionTimedOut: Cannot connect to 127.0.0.1:8090 28 October 2010 6:23:58.673 pm VM: Mac OS - Smalltalk Image: Squeak4.1 [latest update: #9957] SecurityManager state: Restricted: false FileAccess: true SocketAccess: true Working Dir /Users/sean/Squeak/Main Working Images/Squeak4.1 Trusted Dir /foobar/tooBar/forSqueak/bogus Untrusted Dir /Users/sean/Library/Preferences/Squeak/Internet/My Squeak [] in Socket>>connectTo:port:waitForConnectionFor: Receiver: a Socket[unconnected] Arguments and temporary variables: <<error during printing> Receiver's instance variables: semaphore: a Semaphore() socketHandle: #[52 74 202 76 0 0 0 0 64 114 35 0] readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false Socket>>waitForConnectionFor:ifTimedOut: Receiver: a Socket[unconnected] Arguments and temporary variables: timeout: 45 timeoutBlock: [closure] in Socket>>connectTo:port:waitForConnectionFor: status: 0 deadline: 672266 Receiver's instance variables: semaphore: a Semaphore() socketHandle: #[52 74 202 76 0 0 0 0 64 114 35 0] readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false Socket>>connectTo:port:waitForConnectionFor: Receiver: a Socket[unconnected] Arguments and temporary variables: hostAddress: #[127 0 0 1] port: 8090 timeout: 45 Receiver's instance variables: semaphore: a Semaphore() socketHandle: #[52 74 202 76 0 0 0 0 64 114 35 0] readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false Socket>>connectTo:port: Receiver: a Socket[unconnected] Arguments and temporary variables: hostAddress: #[127 0 0 1] port: 8090 Receiver's instance variables: semaphore: a Semaphore() socketHandle: #[52 74 202 76 0 0 0 0 64 114 35 0] readSemaphore: a Semaphore() writeSemaphore: a Semaphore() primitiveOnlySupportsOneSemaphore: false --- The full stack --- [] in Socket>>connectTo:port:waitForConnectionFor: Socket>>waitForConnectionFor:ifTimedOut: Socket>>connectTo:port:waitForConnectionFor: Socket>>connectTo:port: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SocketStream class>>openConnectionToHost:port: SocketStream class>>openConnectionToHostNamed:port: WebClient>>connect WebClient>>sendRequest:contentBlock: WebClient>>sendRequest:content:size: WebClient>>sendRequest: WebClient>>httpGet:do: WebClient>>httpGet: WebClient class>>httpGet: UndefinedObject>>DoIt Compiler>>evaluate:in:to:notifying:ifFail:logged: [] in SmalltalkEditor(TextEditor)>>evaluateSelection BlockClosure>>on:do: SmalltalkEditor(TextEditor)>>evaluateSelection SmalltalkEditor(TextEditor)>>inspectIt SmalltalkEditor(TextEditor)>>inspectIt: SmalltalkEditor(TextEditor)>>dispatchOnCharacter:with: SmalltalkEditor(TextEditor)>>readKeyboard [] in TextMorphForEditView(TextMorph)>>keyStroke: TextMorphForEditView(TextMorph)>>handleInteraction:fromEvent: TextMorphForEditView>>handleInteraction:fromEvent: TextMorphForEditView(TextMorph)>>keyStroke: TextMorphForEditView>>keyStroke: TextMorphForEditView(TextMorph)>>handleKeystroke: KeyboardEvent>>sentTo: TextMorphForEditView(Morph)>>handleEvent: TextMorphForEditView(Morph)>>handleFocusEvent: [] in HandMorph>>sendFocusEvent:to:clear: [] in PasteUpMorph>>becomeActiveDuring: BlockClosure>>on:do: PasteUpMorph>>becomeActiveDuring: HandMorph>>sendFocusEvent:to:clear: HandMorph>>sendEvent:focus:clear: HandMorph>>sendKeyboardEvent: HandMorph>>handleEvent: HandMorph>>processEvents [] in WorldState>>doOneCycleNowFor: Array(SequenceableCollection)>>do: WorldState>>handsDo: WorldState>>doOneCycleNowFor: WorldState>>doOneCycleFor: PasteUpMorph>>doOneCycle [] in Project class>>spawnNewProcess [] in BlockClosure>>newProcess
Cheers,
Sean |
On 29/10/10 12:34 AM, Sean P. DeNigris wrote:
> > When using WebClient, "WebClient httpGet: 'http://google.com'" succeeded, but > "WebClient httpGet: '<a href="http://localhost:8090'">http://localhost:8090'" reported "ConnectionTimedOut: > Cannot connect to 127.0.0.1:8090" > > The address looked fine from Safari. What gives? Some ideas: - It's really 8090 (that's a nine), not 8080? - Are there any proxy configurations involved - Could it be an IPv6 issue |
Administrator
|
Yes, I kept changing it to make sure it wasn't a problem with that particular port I don't know what that means, but for more context, I started a Ruby TCPServer on that port, and then tried to "get" from Squeak, then from Safari I don't know what that means, either, lol. Sean
Cheers,
Sean |
On 10/28/10 11:01 PM, Sean P. DeNigris wrote:
> > Yanni Chiu wrote: >> - It's really 8090 (that's a nine), not 8080? >> > Yes, I kept changing it to make sure it wasn't a problem with that > particular port > > > Yanni Chiu wrote: >> - Are there any proxy configurations involved >> > I don't know what that means, but for more context, I started a Ruby > TCPServer on that port, and then tried to "get" from Squeak, then from > Safari Different scripting libraries can have oddities that the more mainstream c-based ones don't have. I once found an error in the Mac's Python TCP client code that randomly prepended header data into xmlrpc content. Its possible that Ruby is doing something that Safari libs are robust enough to compensate for, or its possible that Ruby is just fine and there's an obscure bug in the Squeak lib that you happen to be the first to find. Lawson |
Administrator
|
I think not. I tried several different ports in the 80xx range with the same result. Sean
Cheers,
Sean |
In reply to this post by Sean P. DeNigris
On 2010/10/29 08:01, Sean P. DeNigris wrote:
> > > Yanni Chiu wrote: >> >> - It's really 8090 (that's a nine), not 8080? >> > Yes, I kept changing it to make sure it wasn't a problem with that > particular port > > > Yanni Chiu wrote: >> >> - Are there any proxy configurations involved >> > I don't know what that means, but for more context, I started a Ruby > TCPServer on that port, and then tried to "get" from Squeak, then from > Safari > > > Yanni Chiu wrote: >> >> - Could it be an IPv6 issue >> > I don't know what that means, either, lol. It means that you could try access http://127.0.0.1:8090/. If that works, then it's likely that Safari's actually trying to access http://[::1]:80/ - and you might not be running anything there. You can check by running netstat -anp tcp and looking for the relevant line. Something like tcp4 0 0 *.8090 *.* LISTEN without a line like tcp6 0 0 *.8090 *.* LISTEN for instance. frank |
In reply to this post by Yanni Chiu
I tested in a mac (10.6.4) using pydoc -p 8090 as the server and works ok:
> WebClient httpGet: '<a href="http://localhost:8090'">http://localhost:8090' > WebResponse(HTTP/1.0 200 OK > server: BaseHTTP/0.3 Python/2.6.4 > date: Fri, 29 Oct 2010 16:02:12 GMT > content-type: text/html > > ) On 29/10/2010, at 00:36, Yanni Chiu wrote: > On 29/10/10 12:34 AM, Sean P. DeNigris wrote: >> >> When using WebClient, "WebClient httpGet: 'http://google.com'" succeeded, but >> "WebClient httpGet: '<a href="http://localhost:8090'">http://localhost:8090'" reported "ConnectionTimedOut: >> Cannot connect to 127.0.0.1:8090" >> >> The address looked fine from Safari. What gives? > > Some ideas: > > - It's really 8090 (that's a nine), not 8080? > - Are there any proxy configurations involved > - Could it be an IPv6 issue > > |
In reply to this post by Sean P. DeNigris
On 29/10/10 2:01 AM, Sean P. DeNigris wrote:
> >> - Are there any proxy configurations involved >> > I don't know what that means, but for more context, I started a Ruby > TCPServer on that port, and then tried to "get" from Squeak, then from > Safari I don't use WebClient, but I recall some posts about configuring it for proxies. If you're not on a corporate network, you probably don't have a proxy. Previously, a newly imaged corporate machine would land on my desk. The IE browser configuration already had various domains configured to bypass the proxy. We developers had to test with Firefox, so we had to configure the proxy in Firefox. If "localhost" were not added to the bypass the proxy list, then we would never reach the app running on our local machine, because it would try to go through the corporate proxy to filter the "localhost" access. >> - Could it be an IPv6 issue >> > I don't know what that means, either, lol. In the /etc/hosts on my Mac, I have: 127.0.0.1 localhost ::1 localhost I can't remember whether I added the 127.0.0.1 entry, or it was already there. I do recall having to add it on some machine though. The 127.0.0.1 is and IPv4 address, and (I'm no IPv6 expert) the ::1 is an IPv6 address. |
Administrator
|
In reply to this post by Frank Shearar
Thanks. I got: ~$ netstat -anp tcp Active Internet connections (including servers) Proto Recv-Q Send-Q Local Address Foreign Address (state) tcp6 0 0 ::1.8090 *.* LISTEN ... That was the only entry for that port. Is that what I should be seeing? Sean
Cheers,
Sean |
Administrator
|
In reply to this post by Yanni Chiu
I'm not Me too. Thanks. Sean
Cheers,
Sean |
Administrator
|
In reply to this post by Sean P. DeNigris
How do I debug this to get a clearer idea of what is going on? For the moment I can use files instead of sockets, but I'll need to use this server approach quickly.
Thanks. Sean
Cheers,
Sean |
In reply to this post by Sean P. DeNigris
On 2010/10/29 19:23, Sean P. DeNigris wrote:
> > > Frank Shearar wrote: >> >>>> - Could it be an IPv6 issue >> It means that you could try access http://127.0.0.1:8090/. If that >> works, then it's likely that Safari's actually trying to access >> http://[::1]:80/ - and you might not be running anything there. >> > > Thanks. I got: > ~$ netstat -anp tcp > Active Internet connections (including servers) > Proto Recv-Q Send-Q Local Address Foreign Address (state) > tcp6 0 0 ::1.8090 *.* LISTEN > ... > > That was the only entry for that port. Is that what I should be seeing? It means that Safari might be resolving "localhost" as the IPv4 address 127.0.0.1 and trying to contact that IP/port, and of course failing. Your next step, I suspect, will be to fire up tcpdump and confirm that that's the case. Start tcpdump with something like: sudo tcpdump -i fw0 -v port 8090 and then trying to access the site through Safari. frank |
In reply to this post by Sean P. DeNigris
If you send the ruby script you're using for running the TCPServer?
Cheers, - Andreas On 10/28/2010 11:01 PM, Sean P. DeNigris wrote: > > > Yanni Chiu wrote: >> >> - It's really 8090 (that's a nine), not 8080? >> > Yes, I kept changing it to make sure it wasn't a problem with that > particular port > > > Yanni Chiu wrote: >> >> - Are there any proxy configurations involved >> > I don't know what that means, but for more context, I started a Ruby > TCPServer on that port, and then tried to "get" from Squeak, then from > Safari > > > Yanni Chiu wrote: >> >> - Could it be an IPv6 issue >> > I don't know what that means, either, lol. > > Sean |
Administrator
|
In reply to this post by Frank Shearar
Exciting! WebClient is communicating, just not successfully. After a little playing around, running "sudo tcpdump -i lo0 -vnS port 2002" (I keep changing the port) produced the following packet info: Safari's first packet: 08:44:10.841003 IP6 (hlim 64, next-header TCP (6) payload length: 44) ::1.54889 > ::1.2002: Flags [S], cksum 0x9345 (correct), seq 2994624526, win 65535, options [mss 16324,nop,wscale 2,nop,nop,TS val 1034896177 ecr 0,sackOK,eol], length 0 WebClient's first packet: 08:39:48.796371 IP (tos 0x0, ttl 64, id 52777, offset 0, flags [DF], proto TCP (6), length 52, bad cksum 0 (->6e98)!) 127.0.0.1.54859 > 127.0.0.1.2002: Flags [F.], cksum 0xfe28 (incorrect -> 0xa0fd), seq 964011037, ack 1862845032, win 65535, options [nop,nop,TS val 1034893560 ecr 1034892868], length 0 Any packet guru know what this means? Thanks for the support so far - I'm really wanting to get this project up and this seems like progress!!! Sean
Cheers,
Sean |
Administrator
|
In reply to this post by Andreas.Raab
Duh, I kept thinking that and forgot...
I tried a few different examples: 1. Starting with the one from the pickaxe book: server = TCPServer.new('localhost', 8091) while (session = server.accept) puts "Request: #{session.gets}" session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n" session.print "<html><body> #{Time.now}</body></html>\r\n"session.close end 2. server = TCPServer.open(2002) # Socket to listen on port 2000 loop { # Servers run forever client = server.accept # Wait for a client to connect client.puts(Time.now.ctime) # Send the time to the client client.puts "Closing the connection. Bye!" client.close # Disconnect from the client } 3. server = TCPServer.new('localhost', 8091) while (true) begin sock = server.accept_nonblock rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR IO.select([server]) retry end sock.print "sdflkdsjfslkdj" sock.close end All three work in Safari and fail in WebClient. Thanks. Sean
Cheers,
Sean |
In reply to this post by Sean P. DeNigris
On 2010/10/29 20:48, Sean P. DeNigris wrote:
> > > Frank Shearar wrote: >> >> Start tcpdump with something like: sudo tcpdump -i fw0 -v port 8090 and >> then trying to access the site through Safari. >> > > Exciting! WebClient is communicating, just not successfully. > > After a little playing around, running "sudo tcpdump -i lo0 -vnS port 2002" > (I keep changing the port) produced the following packet info: > Safari's first packet: > 08:44:10.841003 IP6 (hlim 64, next-header TCP (6) payload length: 44) > ::1.54889> ::1.2002: Flags [S], cksum 0x9345 (correct), seq 2994624526, win > 65535, options [mss 16324,nop,wscale 2,nop,nop,TS val 1034896177 ecr > 0,sackOK,eol], length 0 > WebClient's first packet: > 08:39:48.796371 IP (tos 0x0, ttl 64, id 52777, offset 0, flags [DF], > proto TCP (6), length 52, bad cksum 0 (->6e98)!) > 127.0.0.1.54859> 127.0.0.1.2002: Flags [F.], cksum 0xfe28 (incorrect -> > 0xa0fd), seq 964011037, ack 1862845032, win 65535, options [nop,nop,TS val > 1034893560 ecr 1034892868], length 0 > > Any packet guru know what this means? > > Thanks for the support so far - I'm really wanting to get this project up > and this seems like progress!!! > Sean It looks like Safari's resolving "localhost" to ::1, IPv6's loopback, and the address on which your server's running, while WebClient isn't. WebClient, instead, is resolving "localhost" to 127.0.0.1, IPv4's loopback. There's nothing running there, so the connection fails. Both behaviours are correct, or at least partially so. It's a policy decision whether to try IPv4 addresses or IPv6 addresses first. After that, it makes sense to try all the addresses (switching from 4 to 6 or vice versa) before failing. I don't know how WebClient's name resolution works, so we'll have to wait for Andreas, I think. frank |
In reply to this post by Sean P. DeNigris
On 2010/10/29 21:04, Sean P. DeNigris wrote:
> > Duh, I kept thinking that and forgot... > > I tried a few different examples: > 1. Starting with the one from the pickaxe book: > server = TCPServer.new('localhost', 8091) > while (session = server.accept) > puts "Request: #{session.gets}" > session.print "HTTP/1.1 200/OK\r\nContent-type: text/html\r\n\r\n" > session.print "<html><body><h1>#{Time.now}</h1></body></html>\r\n" > session.close > end > > 2. server = TCPServer.open(2002) # Socket to listen on port 2000 > loop { # Servers run forever > client = server.accept # Wait for a client to connect > client.puts(Time.now.ctime) # Send the time to the client > client.puts "Closing the connection. Bye!" > client.close # Disconnect from the client > } > > 3. server = TCPServer.new('localhost', 8091) > while (true) > begin > sock = server.accept_nonblock > rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EPROTO, Errno::EINTR > IO.select([server]) > retry > end > sock.print "sdflkdsjfslkdj" > sock.close > end > > All three work in Safari and fail in WebClient. I'll put my neck on the block and boldly claim that if you change 'localhost' to '127.0.0.1' WebClient will work. frank |
Administrator
|
#$%!@$ *@#$ &!*!# $*!%! &$!&$!&%$ *!#$ *!#$!#!!!!!!!! It was that freaking easy?!?!?! Thanks. Sean
Cheers,
Sean |
On 2010/10/29 21:39, Sean P. DeNigris wrote:
> > > Frank Shearar wrote: >> >> I'll put my neck on the block and boldly claim that if you change >> 'localhost' to '127.0.0.1' WebClient will work. >> > > #$%!@$ *@#$&!*!# $*!%!&$!&$!&%$ *!#$ *!#$!#!!!!!!!! > > It was that freaking easy?!?!?! > > Thanks. Haha! I'm glad we sorted out your problem. I think NetNameResolver might have to be updated to support IPv6: NetNameResolver addressForName: '::1' timeout: 5 --> timeout NetNameResolver addressForName: '127.0.0.1' timeout: 5 --> #[127 0 0 1] (NetNameResolver calls down to the SocketPlugin for the heavy lifting.) frank |
On 29.10.2010, at 22:09, Frank Shearar wrote:
> I think NetNameResolver might have to be updated to support IPv6: > > NetNameResolver addressForName: '::1' timeout: 5 --> timeout > NetNameResolver addressForName: '127.0.0.1' timeout: 5 --> #[127 0 0 1] > > (NetNameResolver calls down to the SocketPlugin for the heavy lifting.) > > frank In current Etoys on a Mac: NetNameResolver addressForName: '::1' timeout: 5 ==> ::1(localhost),0(0) NetNameResolver addressesForName: 'localhost' ==> an OrderedCollection( ::1(localhost),0(0)-inet6-stream-tcp fe80::1%lo0(localhost),0(0)-inet6-stream-tcp 127.0.0.1(localhost),0(0)-inet4-stream-tcp) - Bert - |
Free forum by Nabble | Edit this page |