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

Reconnect does not work #79

Closed
PhillippOhlandt opened this Issue Jan 8, 2018 · 7 comments

Comments

Projects
None yet
2 participants
@PhillippOhlandt

PhillippOhlandt commented Jan 8, 2018

Hey,

I am using Hedwig with the IRC adapter on a Slack channel. I noticed that Slack sometimes sends a :disconnected message which is unhandled. So I extended the IRC adapter with the following function:

  def handle_info(:disconnected, state = {robot, _opts, _client}) do
    Hedwig.Robot.handle_disconnect(robot, nil)
    {:noreply, state}
  end

And my robot module contains:

  def handle_disconnect(_reason, state) do
    IO.puts "handle disconnect"
    {:reconnect, 5000, state}
  end

So when I start the bot with a slightly wrong configuration (so Slack disconnects me right away) I get the following:

12:27:31.190 [debug] Unknown message: {:unrecognized, "004", %IrcMessage{args: ["phillipp", "IRC-SLACK gateway"], cmd: "004", ctcp: false, host: [], nick: [], server: "irc.tinyspeck.com", user: []}}

12:27:36.183 [debug] Unknown message: {:received, "SSL connection required", %ExIrc.SenderInfo{host: [], nick: "slackbot", user: []}}

12:27:36.184 [debug] Unknown message: {:unrecognized, "444", %IrcMessage{args: ["phillipp", "SSL connection required"], cmd: "444", ctcp: false, host: [], nick: [], server: [], user: []}}
handle disconnect

12:27:36.190 [info]  'Connection to elixir-lang.irc.slack.com:6667 closed!'

As you can see, my handle_disconnect/2 function gets called but the bot itself does not reconnect.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Jan 8, 2018

Short workaround is to just let it crash™.

  def handle_disconnect(_reason, state) do
    raise Foo
    {:reconnect, 5000, state}
  end

PhillippOhlandt commented Jan 8, 2018

Short workaround is to just let it crash™.

  def handle_disconnect(_reason, state) do
    raise Foo
    {:reconnect, 5000, state}
  end
@scrogson

This comment has been minimized.

Show comment
Hide comment
@scrogson

scrogson Jan 8, 2018

Member

@PhillippOhlandt it appears that the IRC adapter is not up-to-date with Hedwig 1.0. It's still using rc.3. It's possible that it isn't handling those messages properly.

Member

scrogson commented Jan 8, 2018

@PhillippOhlandt it appears that the IRC adapter is not up-to-date with Hedwig 1.0. It's still using rc.3. It's possible that it isn't handling those messages properly.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Jan 8, 2018

@scrogson Ah that could explain it. Unfortunately, I don't think the maintainer will update it anytime soon. I think about cloning it and making a special version for the Slack IRC Bridge.

BTW, how is Hedwig 2.0 going? I saw the PR.

PhillippOhlandt commented Jan 8, 2018

@scrogson Ah that could explain it. Unfortunately, I don't think the maintainer will update it anytime soon. I think about cloning it and making a special version for the Slack IRC Bridge.

BTW, how is Hedwig 2.0 going? I saw the PR.

@scrogson

This comment has been minimized.

Show comment
Hide comment
@scrogson

scrogson Jan 8, 2018

Member

@PhillippOhlandt I work with the author...I'll ask if he wouldn't mind updating it.

As for 2.0...I haven't had much time to work on it recently. But now that you're asking...I might try to find time to finish up that PR soon 😉

Member

scrogson commented Jan 8, 2018

@PhillippOhlandt I work with the author...I'll ask if he wouldn't mind updating it.

As for 2.0...I haven't had much time to work on it recently. But now that you're asking...I might try to find time to finish up that PR soon 😉

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Jan 8, 2018

No pressure, everything works fine right now (even with the reconnect workaround) :)

PhillippOhlandt commented Jan 8, 2018

No pressure, everything works fine right now (even with the reconnect workaround) :)

@scrogson

This comment has been minimized.

Show comment
Hide comment
@scrogson

scrogson Jan 26, 2018

Member

@PhillippOhlandt can we call this closed then?

Member

scrogson commented Jan 26, 2018

@PhillippOhlandt can we call this closed then?

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Jan 27, 2018

@scrogson I think so since this needs to be fixed in the adapter (if not already).

PhillippOhlandt commented Jan 27, 2018

@scrogson I think so since this needs to be fixed in the adapter (if not already).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment