Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
On Jun 4, 2010, at 15:15 , aditya siram wrote: Doing (1) solves my problem. What did I do and why did it work? Thanks a lot for your help! Its the problem I pointed out; you are doing an IPv4 connect but "localhost" was resolving to an IPv6 address. This is annoyingly common on Linux. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
Doing (1) solves my problem. What did I do and why did it work? Thanks a lot for your help! -deech On 6/4/10, Roman Cheplyaka wrote: > Confirm if any of the following solves the problem: > > 1. commenting out (by prepending putting hash sign '#' in the beginning >of the line) the following line in /etc/hosts: > > ::1 localhost ip6-localhost ip6-loopback > > 2. executing as root the following command: > > rmmod ipv6 > > * aditya siram [2010-06-04 13:51:29-0500] >> Here's my GHCI session (with my network card off): >> Prelude Network Network.Socket> connectTo "localhost" (PortNumber 3000) >> *** Exception: connect: does not exist (Connection refused) >> Prelude Network Network.Socket> connectTo "127.0.0.1" (PortNumber 3000) >> {handle: } >> >> The OS is Ubuntu (Lucid) Linux. The contents of "/etc/hosts" and >> "/etc/nsswitch.conf" are: >> >> > cat /etc/nsswitch.conf >> # /etc/nsswitch.conf >> # >> # Example configuration of GNU Name Service Switch functionality. >> # If you have the `glibc-doc-reference' and `info' packages installed, >> try: >> # `info libc "Name Service Switch"' for information about this file. >> >> passwd: compat >> group: compat >> shadow: compat >> >> hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 >> networks: files >> >> protocols: db files >> services: db files >> ethers: db files >> rpc:db files >> >> netgroup: nis >> >> > cat /etc/hosts >> 127.0.0.1 localhost >> 127.0.1.1 deech-mac-ubuntu >> >> # The following lines are desirable for IPv6 capable hosts >> ::1 localhost ip6-localhost ip6-loopback >> fe00::0 ip6-localnet >> ff00::0 ip6-mcastprefix >> ff02::1 ip6-allnodes >> ff02::2 ip6-allrouters >> ff02::3 ip6-allhosts >> >> >> -deech >> >> On 6/4/10, Roman Cheplyaka wrote: >> > * aditya siram [2010-06-03 22:30:33-0500] >> >> Hi all, >> >> I had an issue where using the connectTo [1] function would fail to >> >> connect to "localhost" if my wireless card was turned off. The moment >> >> I turned on my wireless connection it worked. But if I use connectTo >> >> with "127.0.0.1" [2] with my network off it works. >> >> >> >> I confirmed that "localhost' resolves to "127.0.0.1" by pinging >> >> "localhost" from command line with the Internet off. >> >> >> >> Is this a bug in "connectTo"? >> >> >> >> -deech >> >> >> >> [1] connectTo "localhost" (PortNumber some_number) >> >> [2] connectTo "127.0.0.1" (PortNumber some_number) >> > >> > How exactly did it fail? Did it throw an exception? If so, what was the >> > exception? >> > >> > Which operating system did you observe that under? >> > >> > If that was Linux, can you show the contents of the following files on >> > that system: >> > >> > /etc/nsswitch.conf >> > /etc/hosts >> > >> > -- >> > Roman I. Cheplyaka :: http://ro-che.info/ >> > "Don't let school get in the way of your education." - Mark Twain >> > ___ >> > Haskell-Cafe mailing list >> > Haskell-Cafe@haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > "Don't let school get in the way of your education." - Mark Twain > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Issue with "connectTo" function in "network" package
Here's my GHCI session (with my network card off): Prelude Network Network.Socket> connectTo "localhost" (PortNumber 3000) *** Exception: connect: does not exist (Connection refused) Prelude Network Network.Socket> connectTo "127.0.0.1" (PortNumber 3000) {handle: } The OS is Ubuntu (Lucid) Linux. The contents of "/etc/hosts" and "/etc/nsswitch.conf" are: > cat /etc/nsswitch.conf # /etc/nsswitch.conf # # Example configuration of GNU Name Service Switch functionality. # If you have the `glibc-doc-reference' and `info' packages installed, try: # `info libc "Name Service Switch"' for information about this file. passwd: compat group: compat shadow: compat hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 networks: files protocols: db files services: db files ethers: db files rpc:db files netgroup: nis > cat /etc/hosts 127.0.0.1 localhost 127.0.1.1 deech-mac-ubuntu # The following lines are desirable for IPv6 capable hosts ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts -deech On 6/4/10, Roman Cheplyaka wrote: > * aditya siram [2010-06-03 22:30:33-0500] >> Hi all, >> I had an issue where using the connectTo [1] function would fail to >> connect to "localhost" if my wireless card was turned off. The moment >> I turned on my wireless connection it worked. But if I use connectTo >> with "127.0.0.1" [2] with my network off it works. >> >> I confirmed that "localhost' resolves to "127.0.0.1" by pinging >> "localhost" from command line with the Internet off. >> >> Is this a bug in "connectTo"? >> >> -deech >> >> [1] connectTo "localhost" (PortNumber some_number) >> [2] connectTo "127.0.0.1" (PortNumber some_number) > > How exactly did it fail? Did it throw an exception? If so, what was the > exception? > > Which operating system did you observe that under? > > If that was Linux, can you show the contents of the following files on > that system: > > /etc/nsswitch.conf > /etc/hosts > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > "Don't let school get in the way of your education." - Mark Twain > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
Another way round -- "it" (the server) was only listening on IPv4 and the (Haskell) client only tried to connect via IPv6. The bug is described here (with a patch): http://trac.haskell.org/network/ticket/30 * Jeremy Shaw [2010-06-04 16:57:38-0500] > Perhaps it was only listening on IPv6 ? ::1 ? > > - jeremy > > On Thu, Jun 3, 2010 at 10:30 PM, aditya siram wrote: > > > Hi all, > > I had an issue where using the connectTo [1] function would fail to > > connect to "localhost" if my wireless card was turned off. The moment > > I turned on my wireless connection it worked. But if I use connectTo > > with "127.0.0.1" [2] with my network off it works. > > > > I confirmed that "localhost' resolves to "127.0.0.1" by pinging > > "localhost" from command line with the Internet off. > > > > Is this a bug in "connectTo"? > > > > -deech > > > > [1] connectTo "localhost" (PortNumber some_number) > > [2] connectTo "127.0.0.1" (PortNumber some_number) > > ___ > > Haskell-Cafe mailing list > > Haskell-Cafe@haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
Yeah, that seems to be the issue. When I commented out the "::1.." line it worked. -deech On 6/4/10, Jeremy Shaw wrote: > Perhaps it was only listening on IPv6 ? ::1 ? > > - jeremy > > On Thu, Jun 3, 2010 at 10:30 PM, aditya siram wrote: > >> Hi all, >> I had an issue where using the connectTo [1] function would fail to >> connect to "localhost" if my wireless card was turned off. The moment >> I turned on my wireless connection it worked. But if I use connectTo >> with "127.0.0.1" [2] with my network off it works. >> >> I confirmed that "localhost' resolves to "127.0.0.1" by pinging >> "localhost" from command line with the Internet off. >> >> Is this a bug in "connectTo"? >> >> -deech >> >> [1] connectTo "localhost" (PortNumber some_number) >> [2] connectTo "127.0.0.1" (PortNumber some_number) >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
Great! If there is a wiki or FAQ page for networking with Haskell it might be worth updating. -deech On 6/4/10, Roman Cheplyaka wrote: > /etc/hosts is the file responsible for resolving 'localhost' hostname. > As you can see from it, there are two entries for localhost: one > contains IPv4 address (127.0.0.1) and another contains IPv6 address > (::1). > > The behaviour you observe is kinda bug in connectTo function. Instead of > trying all of the addresses, this function just tries the first one. > Until it is fixed (I'm gonna write and send a patch soon), can you live > with this temporary hack? If for some reason the answer is "no", you > have to use low-level functions from Network.Socket module for now. > > > * aditya siram [2010-06-04 14:15:47-0500] >> Doing (1) solves my problem. What did I do and why did it work? Thanks >> a lot for your help! >> -deech >> >> On 6/4/10, Roman Cheplyaka wrote: >> > Confirm if any of the following solves the problem: >> > >> > 1. commenting out (by prepending putting hash sign '#' in the beginning >> >of the line) the following line in /etc/hosts: >> > >> > ::1 localhost ip6-localhost ip6-loopback >> > >> > 2. executing as root the following command: >> > >> > rmmod ipv6 >> > >> > * aditya siram [2010-06-04 13:51:29-0500] >> >> Here's my GHCI session (with my network card off): >> >> Prelude Network Network.Socket> connectTo "localhost" (PortNumber 3000) >> >> *** Exception: connect: does not exist (Connection refused) >> >> Prelude Network Network.Socket> connectTo "127.0.0.1" (PortNumber 3000) >> >> {handle: } >> >> >> >> The OS is Ubuntu (Lucid) Linux. The contents of "/etc/hosts" and >> >> "/etc/nsswitch.conf" are: >> >> >> >> > cat /etc/nsswitch.conf >> >> # /etc/nsswitch.conf >> >> # >> >> # Example configuration of GNU Name Service Switch functionality. >> >> # If you have the `glibc-doc-reference' and `info' packages installed, >> >> try: >> >> # `info libc "Name Service Switch"' for information about this file. >> >> >> >> passwd: compat >> >> group: compat >> >> shadow: compat >> >> >> >> hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 >> >> networks: files >> >> >> >> protocols: db files >> >> services: db files >> >> ethers: db files >> >> rpc:db files >> >> >> >> netgroup: nis >> >> >> >> > cat /etc/hosts >> >> 127.0.0.1 localhost >> >> 127.0.1.1 deech-mac-ubuntu >> >> >> >> # The following lines are desirable for IPv6 capable hosts >> >> ::1 localhost ip6-localhost ip6-loopback >> >> fe00::0 ip6-localnet >> >> ff00::0 ip6-mcastprefix >> >> ff02::1 ip6-allnodes >> >> ff02::2 ip6-allrouters >> >> ff02::3 ip6-allhosts >> >> >> >> >> >> -deech >> >> >> >> On 6/4/10, Roman Cheplyaka wrote: >> >> > * aditya siram [2010-06-03 22:30:33-0500] >> >> >> Hi all, >> >> >> I had an issue where using the connectTo [1] function would fail to >> >> >> connect to "localhost" if my wireless card was turned off. The >> >> >> moment >> >> >> I turned on my wireless connection it worked. But if I use connectTo >> >> >> with "127.0.0.1" [2] with my network off it works. >> >> >> >> >> >> I confirmed that "localhost' resolves to "127.0.0.1" by pinging >> >> >> "localhost" from command line with the Internet off. >> >> >> >> >> >> Is this a bug in "connectTo"? >> >> >> >> >> >> -deech >> >> >> >> >> >> [1] connectTo "localhost" (PortNumber some_number) >> >> >> [2] connectTo "127.0.0.1" (PortNumber some_number) >> >> > >> >> > How exactly did it fail? Did it throw an exception? If so, what was >> >> > the >> >> > exception? >> >> > >> >> > Which operating system did you observe that under? >> >> > >> >> > If that was Linux, can you show the contents of the following files >> >> > on >> >> > that system: >> >> > >> >> > /etc/nsswitch.conf >> >> > /etc/hosts >> >> > >> >> > -- >> >> > Roman I. Cheplyaka :: http://ro-che.info/ >> >> > "Don't let school get in the way of your education." - Mark Twain >> >> > ___ >> >> > Haskell-Cafe mailing list >> >> > Haskell-Cafe@haskell.org >> >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > >> > >> > -- >> > Roman I. Cheplyaka :: http://ro-che.info/ >> > "Don't let school get in the way of your education." - Mark Twain >> > > > -- > Roman I. Cheplyaka :: http://ro-che.info/ > "Don't let school get in the way of your education." - Mark Twain > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
Perhaps it was only listening on IPv6 ? ::1 ? - jeremy On Thu, Jun 3, 2010 at 10:30 PM, aditya siram wrote: > Hi all, > I had an issue where using the connectTo [1] function would fail to > connect to "localhost" if my wireless card was turned off. The moment > I turned on my wireless connection it worked. But if I use connectTo > with "127.0.0.1" [2] with my network off it works. > > I confirmed that "localhost' resolves to "127.0.0.1" by pinging > "localhost" from command line with the Internet off. > > Is this a bug in "connectTo"? > > -deech > > [1] connectTo "localhost" (PortNumber some_number) > [2] connectTo "127.0.0.1" (PortNumber some_number) > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Issue with "connectTo" function in "network" package
* aditya siram [2010-06-03 22:30:33-0500] > Hi all, > I had an issue where using the connectTo [1] function would fail to > connect to "localhost" if my wireless card was turned off. The moment > I turned on my wireless connection it worked. But if I use connectTo > with "127.0.0.1" [2] with my network off it works. > > I confirmed that "localhost' resolves to "127.0.0.1" by pinging > "localhost" from command line with the Internet off. > > Is this a bug in "connectTo"? > > -deech > > [1] connectTo "localhost" (PortNumber some_number) > [2] connectTo "127.0.0.1" (PortNumber some_number) How exactly did it fail? Did it throw an exception? If so, what was the exception? Which operating system did you observe that under? If that was Linux, can you show the contents of the following files on that system: /etc/nsswitch.conf /etc/hosts -- Roman I. Cheplyaka :: http://ro-che.info/ "Don't let school get in the way of your education." - Mark Twain ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Issue with "connectTo" function in "network" package
Hi all, I had an issue where using the connectTo [1] function would fail to connect to "localhost" if my wireless card was turned off. The moment I turned on my wireless connection it worked. But if I use connectTo with "127.0.0.1" [2] with my network off it works. I confirmed that "localhost' resolves to "127.0.0.1" by pinging "localhost" from command line with the Internet off. Is this a bug in "connectTo"? -deech [1] connectTo "localhost" (PortNumber some_number) [2] connectTo "127.0.0.1" (PortNumber some_number) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe