Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irssi reports "SSL handshake failed: Broken pipe" when connecting to Freenode #2846

Closed
pcolmer opened this issue Jan 15, 2018 · 29 comments
Closed

Comments

@pcolmer
Copy link

pcolmer commented Jan 15, 2018

  • Your Windows build number: 10.0.16299.192

  • What you're doing and what's happening: I've installed and configured irssi to use SSL when connecting to Freenode. When I run irssi and try to connect to Freenode, I get this message:

Irssi: warning SSL handshake failed: Broken pipe

A colleague running the same version on "full" Ubuntu is not having this problem. I've tried building and running the latest release and it has the same problem. I've tried using a full Ubuntu system myself and I don't get the issue, suggesting it is a WSL problem.

@jmaher
Copy link

jmaher commented Jan 16, 2018

yeah, I use irssi daily- did the fall creators update (forced on me), and now I cannot connect. I did a "sudo apt-get update" and then "sudo apt-get upgrade", there were a lot of udpates, still this doesn't seem to work.

@sunilmut
Copy link
Member

Please post the repro.

@jmaher
Copy link

jmaher commented Jan 16, 2018

@sunilmut

irssi

[] /server connect irc.mozilla.org 6697

this fails with port 6697 because of ssl

@jmaher
Copy link

jmaher commented Jan 16, 2018

of course I don't know how to use comments on github :(

@pcolmer
Copy link
Author

pcolmer commented Jan 18, 2018

@sunilmut if you are already using irssi, rename ~/.irssi to ~/.irssi-bak just to ensure that you are starting with a known state.

If you haven't got irssi installed, you can either use apt-get or download the sources and build it. I've tried both and the problem affects both.

Then:

  • run irssi
  • /connect ubuntu

You will see messages like this:

09:53 -!- Irssi: Looking up irc.ubuntu.com
09:53 -!- Irssi: Connecting to irc.ubuntu.com [185.30.166.37] port 6697
09:53 -!- Irssi: warning SSL handshake failed: Broken pipe
09:53 -!- Irssi: Connection lost to irc.ubuntu.com

If you want to confirm that this isn't just the Ubuntu servers, edit ~/.irssi/config and find the section for Freenode:

{
   address = "chat.freenode.net";
   chatnet = "Freenode";
   port = "6667";
 },

Change the port from 6667 to 6697 and add this line:

use_ssl = "yes";

so that it looks like this:

{
   address = "chat.freenode.net";
   chatnet = "Freenode";
   port = "6697";
   use_ssl = "yes";
 },

Save the changed file and then go:

  • irssi
  • /connect Freenode

and you'll get a similar message to the one for the Ubuntu failure:

09:56 -!- Irssi: Looking up chat.freenode.net
09:56 -!- Irssi: Connecting to chat.freenode.net [107.182.226.199] port 6697
09:56 -!- Irssi: warning SSL handshake failed: Broken pipe
09:56 -!- Irssi: Connection lost to chat.freenode.net

I should have added that this is with the Ubuntu distro. I have not tested this on other WSL distros.

@therealkenc
Copy link
Collaborator

if you are already using irssi

No that is the gap. A repro would look like a sequence of apt/wget/tar/whatever commands from a clean Ubuntu install per (3) of CONTRIBUTING.md.

@sunilmut
Copy link
Member

Yes, end-to-end repros are much preferred. Helps us focus on the fix.

@pcolmer
Copy link
Author

pcolmer commented Jan 19, 2018

OK ...

sudo apt-get install irssi
irssi
/connect ubuntu

Expected behaviour is that the connect command should succeed, but it doesn't.

@PaJson
Copy link

PaJson commented Jan 20, 2018

I'm not sure if this is relevant or not, but here are my two cents on this issue.

I have reinstalled Ubuntu on WSL three times today because I was trying to get Irssi with SSL working. Each and every time I reinstalled Ubuntu, the first thing I needed to do was a "sudo apt-get update", before I could install Irssi (apt doesn't find the Irssi-package otherwise). So, after "sudo apt-get update" and "sudo apt-get install irssi" I have Irssi installed.

I start Irssi and connect to a server using the following command "/server -ssl irc.server.net 6697", and it works just fine! It connects using SSL! I then "/disconnect" or "/reconnect", and it fails with the error "SSL handshake failed: Broken pipe".

After the first connection I can never get it to connect using SSL again, on ANY server AT ALL! And it doesn't matter if I close my terminal down and start a new one or not. (The only thing I didn't try was to reboot my computer before the next try to connect, but that should not be a solution anyway!)

I'm not sure how Irssi handles it, but maybe it has something to do with accepting (and storing) certificates? When using mIRC, the question always pops up to accept the certificate on connect (unless you tick the box to auto-accept it the next time). Maybe there is something like this that doesn't work for Irssi in conjunction with WSL. Just a thought!

@pcolmer
Copy link
Author

pcolmer commented Jan 23, 2018

@sunilmut Has enough detail been provided for the repo now or are you still missing some information? Please let me know so that I can help you to reproduce the problem.

@sunilmut
Copy link
Member

sunilmut commented Jan 25, 2018

@pcolmer - Sorry for the delay. Yes, I have a repro of the issue.

On my native Ubuntu setup (vm), I see:

19:38 -!- Irssi: Connecting to irc.ubuntu.com [130.185.232.126] port 6697
19:40 -!- Irssi: warning SSL handshake failed: Connection timed out
19:40 -!- Irssi: Connection lost to irc.ubuntu.com

But, on WSL, I see:

19:39 -!- Irssi: Connecting to irc.ubuntu.com [185.30.166.37] port 6697
19:39 -!- Irssi: warning SSL handshake failed: Broken pipe
19:39 -!- Irssi: Connection lost to irc.ubuntu.com

This is your repro, right? You were expecting WSL to behave similar to native Ubuntu?

@PaJson - Thanks for the additional info. That seems useful.

@pcolmer
Copy link
Author

pcolmer commented Jan 30, 2018

@sunilmut The connection to irc.ubuntu.com should succeed on native Ubuntu, which is what I'm expecting to happen on WSL. It is possible that 130.185.232.126 was unavailable at the time you tried for some reason.

Strangely, I've just tried @jmaher's suggestion of:

/server connect irc.mozilla.org 6697

and that works for me. I'm not getting the handshake failure I get on other services.

Also, it looks like irc.ubuntu.com is just pointing at the Freenode servers so maybe it is something about how they've got their SSL configured that is causing problems on WSL?

@bensh
Copy link

bensh commented Feb 12, 2018

Exactly the same issue here connecting to an irc server with SSL. Started after I updated to Fall Creators Update last week.

11:55  --- Server: Looking up host irc.sec
11:55  --- Connecting to irc.sec on port 3840
11:55  warning SSL handshake failed: Broken pipe
11:55  --- Server: Connection lost to irc.sec

@therealkenc
Copy link
Collaborator

So let's do this one. Confirmed that irc.mozilla.org works but ubuntu doesn't. Here is the diverge (this is with irssi 0.8.19-1ubuntu1.6):

WSL 17093:

772   connect(4, {sa_family=AF_INET, sin_port=htons(6697), sin_addr=inet_addr("162.213.39.42")}, 16) = -1 EINPROGRESS (Operation now in progress)
772   fstat(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
772   fcntl(4, F_GETFL)                 = 0x802 (flags O_RDWR|O_NONBLOCK)
772   brk(0x7fffbae86000)               = 0x7fffbae86000
772   open("/dev/urandom", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 5
772   fstat(5, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0
772   poll([{fd=5, events=POLLIN}], 1, 10) = 1 ([{fd=5, revents=POLLIN}])
772   read(5, "\34\226\246i>\264m\217\27\252\322>RE\275Wc\237\16\223[\227\32<(\372p\224o\372\376\254", 32) = 32
772   close(5)                          = 0
772   getuid()                          = 1000
772   time(NULL)                        = 1518452916
772   open("/usr/lib/ssl/cert.pem", O_RDONLY) = -1 ENOENT (No such file or directory)
772   time(NULL)                        = 1518452916
772   time(NULL)                        = 1518452916
772   write(4, "\26\3\1\1C\1\0\1?\3\0033{0\6<\313:\6\336Sj\23\237'|\27\\\30\265d\374"..., 328) = -1 EPIPE (Broken pipe)

Real Linux:

3885  connect(4, {sa_family=AF_INET, sin_port=htons(6697), sin_addr=inet_addr("195.154.200.232")}, 16) = -1 EINPROGRESS (Operation now in progress)
3885  fstat(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
3885  fcntl(4, F_GETFL)                 = 0x802 (flags O_RDWR|O_NONBLOCK)
3885  brk(0x559e1fc03000)               = 0x559e1fc03000
3885  open("/dev/urandom", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 5
3885  fstat(5, {st_mode=S_IFCHR|0666, st_rdev=makedev(1, 9), ...}) = 0
3885  poll([{fd=5, events=POLLIN}], 1, 10) = 1 ([{fd=5, revents=POLLIN}])
3885  read(5, "wH\1~\245Xe\351\345!\307c\342\212;\33=\274\33\fX\372\363\r\273g=}P8\253X", 32) = 32
3885  close(5)                          = 0
3885  getuid()                          = 1000
3885  open("/usr/lib/ssl/cert.pem", O_RDONLY) = -1 ENOENT (No such file or directory)
3885  write(4, "\26\3\1\1C\1\0\1?\3\3\271O\324NJS\204\220/m\307\10\316\0\252/\304\3779\350:"..., 328) = -1 EAGAIN (Resource temporarily unavailable)
3885  write(3, "\1\0\0\0\0\0\0\0", 8)   = 8
3885  write(1, "\33[2;22r\33[2;1H\33[22;1H\33[1S\33[1;24r\33"..., 327) = 327
3885  poll([{fd=0, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN}, {fd=4, events=POLLOUT}], 3, 0) = 1 ([{fd=3, revents=POLLIN}])
3885  rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTORER, 0x7f2c5d246390}, NULL, 8) = 0
3885  poll([{fd=0, events=POLLIN|POLLPRI}, {fd=3, events=POLLIN}, {fd=4, events=POLLOUT}], 3, 512) = 1 ([{fd=3, revents=POLLIN}])

On Real Linux the write() to fd 4 returns EAGAIN and the code goes into a brief retry dance, while on WSL it returns EPIPE, and then everything goes downhill from there. In both runs the command given to irssi was /server connect ubuntu. Note the ip address passed to connect() in the traces above are different but, this appears "normal" after having done a few tries on both WSL and RL.

I haven't looked any further to see what the a successful exchange with irc.mozilla.org looks like, but I'd bet a buck that initial connect just returns 0 instead of EINPROGRESS. Which would be a function of how the server-side behaves.

@mcgoo
Copy link

mcgoo commented Feb 14, 2018

Small test program for the EAGAIN vs EPIPE difference @therealkenc is talking about. I tested 10.0.17093.1000 and it returns EPIPE if the socket is not connected yet. The Linux machine I tested on returns EAGAIN.

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <unistd.h>

int main() {

    int fd = socket( AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0 );
    if (fd < 0)
        perror("socket: ");

    struct sockaddr_in ip4addr;
    ip4addr.sin_family = AF_INET;
    ip4addr.sin_port = htons(80);
    inet_pton(AF_INET, "74.125.69.99", &ip4addr.sin_addr);

    int res = connect(fd, (struct sockaddr*)&ip4addr, sizeof(ip4addr));
    printf("called connect, res=%d ", res);

    ssize_t len = write(fd, "ABDCE", 5);
    if (len < 0)
        perror("write");
    else
        printf("write succeeded");

    return 0;
}

@pcolmer
Copy link
Author

pcolmer commented Feb 28, 2018

Will there be any possibility of this being fixed in time for the upcoming Win10 update?

@sunilmut
Copy link
Member

sunilmut commented Mar 2, 2018

Thanks for the root cause @therealkenc and the test program @mcgoo.

@pcolmer - It's too late for the current major update. But, I have marked this is as a bug and will get to it soon.

@bensh
Copy link

bensh commented May 10, 2018

Any idea when this'll be fixed? it's over 2 months now since the issue root cause was provided.

@neurosys-zero
Copy link

neurosys-zero commented May 10, 2018 via email

@SuperManifolds
Copy link

Also having this issue, is there an ETA?

@mariodigital
Copy link

I searched for Irssi: warning SSL handshake failed: Broken pipe and came here. Please fix this.

@jkunkee
Copy link

jkunkee commented Jun 21, 2018

Thanks to the great info here and thanks to @sunilmut and @benhillis working with me (I'm not a WSL dev here at MSFT), a fix is on its way to Insider Preview builds.

@Brian-Perkins
Copy link

This should be fixed in Insider Build 17713

@manitaggarwal
Copy link

manitaggarwal commented Sep 18, 2018

Just removing the server entry from ~/.irssi/config for freenode or ubuntu works for me.
'irc.mozilla.org' connects as mentioned by @therealkenc because there is no entry of it in the config file.

Windows Vesion - 1803 (OS Build 17134.228)
Running Ubuntu on WSL

@markgross
Copy link

I wonder if there is a race condition going on with this issue.
I am seeing this problem with (Version 10.0.16299 Build 16299) running WSL and ubuntu 18.04 (installed over the weekend)
anyway I was trying to debug the problem and thought that I'd run
strace -o irssi.debug irssi
and found that it worked!!

Looking at the irssi.debug file I notice a suspiciously large number of calls to time API's. I wonder if there is some logic happening with time on the SSL code path that is having a hard time with WSL?

@markgross
Copy link

is 1809 a ubuntu version number? if its the Windows fixed in version number can you help me map 1809 to something like what I find under the control panel? (Version 10.0.16299 Build 16299):

@therealkenc
Copy link
Collaborator

this

@bensh
Copy link

bensh commented Oct 11, 2018

Cortana Search or Setting Search box > 'about' >About your PC
Scroll to Windows Specifications at the bottom and you should see
Edition: .....
Version ..... 1803/1809 etc

@kevaosz
Copy link

kevaosz commented Oct 4, 2023

alguém encontrou a solução?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests