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

Ensure stanzas other than Presence, Message, and IQ don't crash the client. #2

Closed
scrogson opened this issue Oct 8, 2014 · 1 comment
Assignees

Comments

@scrogson
Copy link
Member

scrogson commented Oct 8, 2014

When a client is signed in with a given resource and you attempt to connect another instance with the same resource, you end up with a resource conflict. You will receive the following error stanza:

<stream:error>
  <conflict xmlns='urn:ietf:params:xml:ns:xmpp-streams'></conflict>
  <text xml:lang='en' xmlns='urn:ietf:params:xml:ns:xmpp-streams'>
    Replaced by new connection
  </text>
</stream:error>

This will crash the client.

Error in process <0.9905.0> on node 'hedwig@127.0.0.1' with exit value: {badarg,[{'Elixir.Hedwig.Client',handle_stanza,2,[{file,
"lib/hedwig/client.ex"},{line,77}]},{'Elixir.Hedwig.Conn',await,1,[{file,"lib/hedwig/conn.ex"},{line,137}]}]}

Should probably just ignore when a record gets passed to handle_stanza/2:

def handle_stanza(_pid, stanza) when Record.is_record(stanza) do
  Logger.warn fn -> "Unhandled stanza: #{inspect stanza}" end
end
@scrogson scrogson self-assigned this Oct 8, 2014
@jamesjahraus
Copy link

I also have a similar error that I think is related to this issue:
14:57:29.955 [error] Process #PID<0.157.0> raised an exception
** (BadMapError) expected a map, got: {:xmlstreamend, "stream:stream"}
(hedwig) lib/hedwig/client.ex:78: Hedwig.Client.handle_stanza/2
(hedwig) lib/hedwig/conn.ex:133: Hedwig.Conn.await/1

I tried to modify handle_stanza/2 as you suggested, but I did not correct the problem. I am not too sure how to fix this, a case maybe?

My goal is to get many (1000 +)processes responding to a handler I created, currently I can only get 5, supervisor can not seem to start them fast enough. Looking at the observer the pids are changing very fast, so I assume each client is continually crashing.

Do you have any suggestions to fix handle_stanza/2.

Thanks

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

2 participants