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

Session establishment failed #34

Open
Marcpellet opened this issue Jul 22, 2016 · 8 comments
Open

Session establishment failed #34

Marcpellet opened this issue Jul 22, 2016 · 8 comments

Comments

@Marcpellet
Copy link

Marcpellet commented Jul 22, 2016

Hello

I use openfire 4.0.2 on windows 7 and sharp.xmpp to communicate with the server. Everything worked fine during the testing phase when i used the same name for hostname and server name. I used the example of xmpp connection found in the documentation.

I tried to reinstall the server using a different name for server name and I am unable to connect to the server. The instruction client.connect() rise an exception of type: Exception:Sharp.Xmpp.XmppErrorException: Session establishment failed.

I saw that issue #9 already talks about this exception and tried to enable log plugin to have more
information about the bug, but logs are totally unreadable.

Is there any special configuration to change when both server and host name are different or did I miss something ?

@jpenny1993
Copy link

I'm also using openfire 4.0.2 on Win 2012 R2 an it's working fine (but mine are named the same).
I might have some free time to check this when I get home.

As a temporary fix you could modify your hosts file so that your machine domain matches your server name.

Are you if sure this is happening in EstablishSession() on connect and not on authenticate?
I've had to make my harness ignore exceptions from authenticate and then double check it is authenticated to be able to get around a stream termination bug.

Also could you post a pastebin of the exception details? It might be of help us solve this.

@Marcpellet
Copy link
Author

Thanks for your answer

here is the complete stack trace:


L'exception S22.Xmpp.XmppErrorException n'a pas été gérée
  HResult=-2146233088
  Message=Session establishment failed.
  Source=S22.Xmpp
  StackTrace:
       à S22.Xmpp.Im.XmppIm.EstablishSession()
       à S22.Xmpp.Im.XmppIm.Connect(String resource)
       à S22.Xmpp.Client.XmppClient.Connect(String resource)
       à testSharpXmpp.Program.sendMessages(String hostname, String username, String password, String recipient) dans c:\Users\Marc\Documents\Cours\test c#\testSharpXmpp\testSharpXmpp\Program.cs:ligne 78
       à testSharpXmpp.Program.Main(String[] args) dans c:\Users\Marc\Documents\Cours\test c#\testSharpXmpp\testSharpXmpp\Program.cs:ligne 52
       à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       à System.Threading.ThreadHelper.ThreadStart()


@Marcpellet
Copy link
Author

Oups i didn't notice I had an old version on my test project, I changed to the last library release and the exception persist:

  L'exception Sharp.Xmpp.XmppErrorException n'a pas été gérée
  HResult=-2146233088
  Message=Session establishment failed for Hostname: marcpc
  Source=Sharp.Xmpp
  StackTrace:
       à Sharp.Xmpp.Im.XmppIm.EstablishSession() dans c:\Users\Marc\Documents\Cours\BA6\TB\sharp.xmpp\Sharp.Xmpp\Im\XmppIm.cs:ligne 1528
       à Sharp.Xmpp.Im.XmppIm.Connect(String resource) dans c:\Users\Marc\Documents\Cours\BA6\TB\sharp.xmpp\Sharp.Xmpp\Im\XmppIm.cs:ligne 372
       à Sharp.Xmpp.Client.XmppClient.Connect(String resource) dans c:\Users\Marc\Documents\Cours\BA6\TB\sharp.xmpp\Sharp.Xmpp\Client\XmppClient.cs:ligne 655
       à testSharpXmpp.Program.sendMessages(String hostname, String username, String password, String recipient) dans c:\Users\Marc\Documents\Cours\test c#\testSharpXmpp\testSharpXmpp\Program.cs:ligne 78
       à testSharpXmpp.Program.Main(String[] args) dans c:\Users\Marc\Documents\Cours\test c#\testSharpXmpp\testSharpXmpp\Program.cs:ligne 52
       à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       à System.Threading.ThreadHelper.ThreadStart()

@nairbijesh
Copy link

nairbijesh commented Aug 1, 2016

Well i had same issue and solved it by modifying Library source code. Basically cause for the issue is Library could not able to do "Session Establishment" [XMPP RFC 3921, Section 3] if Host name and Server Name is different.

To solve, i suggest you to do following modification in Library source code.

  1. XMPPClient class should accept one additional parameter 'ServerName' same like Hostname.
  2. EstablishSession() method written in XmppIm Class should use 'Servername' instead of 'Hostname' for Session IQ Request.

@stevenlivz
Copy link

This is quite a significant bug and i'm surprised not to have seen this more. Thanks for the tip - i will fork and mod the source.

@dgenezini
Copy link

dgenezini commented Feb 14, 2017

Any updates on this? What is this Server Name?

@cimframe
Copy link

cimframe commented Apr 1, 2017

nairbijesh - can you please post the actual code for the necessary change?

Thanks,
Steve

@VitorCioletti
Copy link

@stevenlivz actually have done a nice job to fix this. See #41.
Unfortunately there is no published package using this modification. I have asked permission for @stevenlivz to fork his mod in order to publish and maintain it. I'm still getting into the source code but soon it will be published.

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

7 participants