Hi Sven, $ telnet localhost 1701 works perfectly but I noticed that it first tries to connect to ::1 and then switch to 127.0.0.1 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost but I suspected that curl does the same and do not fallback to 127.0.0.1 and yes this one works: curl --ipv4 http://localhost:1701 so by default my curl works on ipv6 I do not know why ::1 is before 127.0.0.1 on my mac 10.9.3. Is there a global option? in /etc/hosts 127.0.0.1 if first anyway, thanks problem solved and not related with Zinc ;-) Luc 2014-06-14 11:03 GMT+02:00 Sven Van Caekenberghe <sven@stfx.eu>:
Luc,
I have seen this kind of weirdness before, but I mostly see it with ab (apache benchmark tool). I really have no idea. Have you tried with telnet to do a manual HTTP request ?
$ telnet localhost 1701 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET /random HTTP/1.1 Host:localhost:1701
HTTP/1.1 200 OK Content-Type: text/plain;charset=utf-8 Content-Length: 64 Date: Sat, 14 Jun 2014 08:58:48 GMT Server: Zinc HTTP Components 1.0
EF97C091498F3FEA3F79F65D36C40ECAFD116A68BA31F45D027DB61EBDD1579 ^] telnet> close Connection closed.
You could also try using the same or a second Pharo image to do the request.
$ ./pharo Pharo.image eval "ZnClient new get: ' http://localhost:8080/random'" '766EF4E6E5664EF4C5163D30125B5C35BFE2AED408835CB6D6206DF0A7A15FD '
In any case, the server socket used is normally listening on all interfaces [0.0.0.0]
Sven
On 14 Jun 2014, at 09:17, Luc Fabresse <luc.fabresse@gmail.com> wrote:
2014-06-14 6:04 GMT+02:00 Ben Coman <btc@openinworld.com>: Luc Fabresse wrote:
Hi,
I experiencing a strange difference between localhost and 127.0.0.1.
In Pharo I do:
(ZnServer startDefaultOn: 4444) onRequestRespond: [ :request | ZnResponse ok: (ZnEntity text:
'hello') ]
In bash:
$ lsof -Pi | grep Pharo Pharo 2718 luc 7u IPv4 0x1e64a2e9381f409b 0t0 TCP *:4444
(LISTEN)
I perfectly listen on port 4444 from all interfaces *
$ curl http://127.0.0.1:4444 hello
$ curl http://localhost:4444 curl: (7) Failed to connect to localhost port 4444: Connection refused
<- why ?
localhost is correctly resolved on my mac $ ping localhost PING localhost (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.044 ms
I tested with other programs than Zinc to open listening sockets and it
works.
Any idea?
#Luc
maybe http://sourceforge.net/p/curl/bugs/1337/
Humm, I use curl 7.36.0, so yes perhaps this bug fix is not integrated...
Anyway, I was also suspecting curl but I tested with server: Apache on port 8888 and here curl works:
httpd 621 luc 5u IPv6 0x6ea19c1d988f10db 0t0 TCP *:8888 <-- same as Zinc
but both:
curl http://127.0.0.1:8888 curl http://localhost:8888
are working.
wget always works (Apache and Zinc):
wget -qO- http://127.0.0.1:8888 wget -qO- http://localhost:8888
Thanks Max and Ben,
Luc