google-code-export / msnp-sharp

Automatically exported from code.google.com/p/msnp-sharp
1 stars 0 forks source link

Unhandled FATAL exception during authentication #314

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
- I've found no reliable way to reproduce the problem. It's intermittent.
- But should be pretty easy to fix from the stacktrace.

What version of the product are you using? (MSNPSharp, OS, Mono etc.)
- MSNPSharp v5.0.0.2717
- Windows 7

Is your code check out from GIT or download from our download site?
- Download

Please provide any additional information below:
- My application is has several "MSNPSharp.Messenger" instances. It allows you 
login to various MSN accounts in the same client.

Error and stacktrace:
2012-02-09 11:13:12,790 [FATAL] 10324 MXit.Core.Application - An unhandled 
exception fubarred your application!
Exception         = System.NullReferenceException: Object reference not set to 
an instance of an object.
   at MSNPSharp.SingleSignOn.GetTickets(RequestSecurityTokenResponseType[] result, SecurityTokenService securService, MSNTicket msnticket)
   at MSNPSharp.SingleSignOn.<>c__DisplayClass2.<Authenticate>b__0(Object sender, RequestMultipleSecurityTokensCompletedEventArgs e)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Sender            = Name:MXit.ChatGateway.Msn.Service.exe
There are no context policies.

CoreServerManager = MXit.Core.Application
{
    ApplicationStartTime= 2012-02-09 11:09:46
    ApplicationUptime   = 0.00:03:26
    ApplicationThreadCount= 48
    MemoryUsage (RAM)   = 146.152 MB
    MemoryUsage (Paged) = 181.461 MB
    MemoryUsage (Private)= 181.586 MB
    MemoryUsage (Virtual)= 5388.738 MB
}

Original issue reported on code.google.com by viljoe...@gmail.com on 9 Feb 2012 at 10:09

GoogleCodeExporter commented 9 years ago
This information is not enough.

Open VisualStudio: Debug - Exceptions - NullReferenceException.
Compile in DEBUG mode and RUN.
And wait NullReferenceException which shows all stack traces and null variable.

Original comment by hepha...@gmail.com on 9 Feb 2012 at 2:44

GoogleCodeExporter commented 9 years ago
Hi Ethem, I believe it's line 640 throws an exception. Let's check the 
GetTickets method.

Original comment by freezing...@gmail.com on 17 Feb 2012 at 10:20

GoogleCodeExporter commented 9 years ago

Original comment by freezing...@gmail.com on 17 Feb 2012 at 10:20

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 991572a3b88e.

Original comment by freezing...@gmail.com on 17 Feb 2012 at 10:34

GoogleCodeExporter commented 9 years ago
Done, please check out from the master branch

Original comment by freezing...@gmail.com on 17 Feb 2012 at 10:40

GoogleCodeExporter commented 9 years ago
I implemented a fix that I've been running on our production system for a few 
days without problems now. I'll post it here as well on Monday.

Original comment by viljoe...@gmail.com on 17 Feb 2012 at 10:42

GoogleCodeExporter commented 9 years ago
Thanks!

Original comment by freezing...@gmail.com on 17 Feb 2012 at 10:51

GoogleCodeExporter commented 9 years ago
NullReference is in GetTickets(). Propably, in token (token.AppliesTo, 
token.RequestedSecurityToken, token.Lifetime.Created, token.Lifetime.Expires).

GetTickets(e.Result, securService, msnticket):
e.result is not null, look stacktrace; we are in GetTickets().

NSMessageHandler.cs:719: You can see onError is not null.

Please revert. Otherwise we can't never find the bug.

Original comment by hepha...@gmail.com on 17 Feb 2012 at 11:10

GoogleCodeExporter commented 9 years ago
No need to reverse, you can debug it by listening AutehticationError, I believe 
the problem arise because of network connection problem (The token request 
failed by connection timeout) so e.Result is null. I will leave this issue 
opened before the reporter post his fix.

Original comment by freezing...@gmail.com on 18 Feb 2012 at 12:21

GoogleCodeExporter commented 9 years ago
Connection and auth errors handled by e.Error.

If e.Result is not null, the response is OK(200). This is async rule.
Ok leave opened. I am sure, the NullReferenceException is in GetTickets().

Original comment by hepha...@gmail.com on 18 Feb 2012 at 12:47

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
OK, I checked. The changes we made to the library were just to check for an 
Exception when calling GetTickets as follows:

                        #region MXit Modification
                        try
                        {
                        #endregion
                            GetTickets(e.Result, securService, msnticket);
                        #region MXit Modification
                        }
                        catch (Exception getTicketsException)
                        {
                            if (onError == null)
                            {
                                throw new Exception("Error in GetTickets", getTicketsException);
                            }
                            else
                            {
                                onError(this, new ExceptionEventArgs(getTicketsException));
                            }
                        }
                        #endregion

The strange thing is, I don't seem to find any error messages containing 
GetTickets in our logs.

The only errors I'm getting are the following:

1) 
2012-02-13 16:00:41,250 [ERROR] 22488 
MXit.ChatGateway.ViaMsnpSharp.MsnGatewaySession - Msn_ServiceOperationFailed: 
UserSession = MXit.ChatGateway.ViaMsnpSharp.MsnGatewaySession
{
    CreateTimestamp     = 2012-02-13 15:40:33.523
    UserId              = m17900198002
    IsLoggedIn          = False
    GatewayAccount      = MXit.ChatGateway.GatewayAccountDetails
    {
        UserId              = m17900198002
        GatewayContactType  = MsnGateway
        LoginName           = Djprince@hotmail.co.za
        AutoLogin           = True
    }
    GatewayBuddies      = 0
    {
    }
    SavedGatewayBuddyAliases= MXit.ChatGateway.GatewayBuddyAliases
    {
        UserId              = m17900198002
        GatewayContactType  = MsnGateway
        BuddyAliases        = 0
        {
        }
    }
    DebugUserMessagesAreEnabled= False
}
Sender = MSNPSharp.ContactService
Exception = System.Web.Services.Protocols.SoapException: Full sync required.  
Details: Client has too old a copy for us to do a delta sync.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.InvokeAsyncCallback(IAsyncResult result)

2)

2012-02-13 21:06:47,560 [ERROR] msn_gateway.session_tasks.001 
MXit.Threading.QueuedTaskThreadPool`1[[MXit.ChatGateway.GatewaySession, 
MXit.ChatGateway, Version=3.1.8.0, Culture=neutral, PublicKeyToken=null]] - 
InvokeTaskCallback: An error occurred while invoking a task's callback function.
ThreadPool = 
MXit.Threading.QueuedTaskThreadPool`1[MXit.ChatGateway.GatewaySession]
{
    Name                        = msn_gateway.session_tasks
    TaskQueueCount              = 0
    ThreadCount                 = 5 [AutoAdjust = False]
    TasksInProgress             = 3 (+316414, -316411, +12/sec, -12/sec)
    ThreadCountAutoAdjusts      = 0 (0/hour)
}
Callback   = 
MXit.Threading.ExecuteTaskDelegate`1[MXit.ChatGateway.GatewaySession]
Context    = MXit.ChatGateway.ViaMsnpSharp.MsnGatewaySession
{
    CreateTimestamp     = 2012-02-13 21:06:47.560
    UserId              = m30686235002
    IsLoggedIn          = False
    GatewayAccount      = MXit.ChatGateway.GatewayAccountDetails
    {
        UserId              = m30686235002
        GatewayContactType  = MsnGateway
        LoginName           = 
        Password            = 
        AutoLogin           = True
    }
    GatewayBuddies      = 0
    {
    }
    SavedGatewayBuddyAliases= MXit.ChatGateway.GatewayBuddyAliases
    {
        UserId              = m30686235002
        GatewayContactType  = MsnGateway
        BuddyAliases        = 0
        {
        }
    }
    DebugUserMessagesAreEnabled= False
}
Exception  = MSNPSharp.MSNPSharpException: The specified account is empty
   at MSNPSharp.Messenger.Connect()
   at MXit.ChatGateway.ViaMsnpSharp.MsnGatewaySession.InitiateLogin() in C:\dev\mxit\core_cs\services\chat_gateway\trunk\MXit.ChatGateway.ViaMsnpSharp\MsnGatewaySession.cs:line 350
   at MXit.Threading.QueuedTaskThreadPool`1.InvokeTaskCallback(ThreadPoolTask`1 task)

Original comment by viljoe...@gmail.com on 20 Feb 2012 at 11:00

GoogleCodeExporter commented 9 years ago
This is your fault.

LoginName seems empty. It must be an email address.

You must set messenger.Credentials.Account before connect.

Please try MSNPSHARP_50_STABLE branch. If the problem still exists re-open this 
issue.

Original comment by hepha...@gmail.com on 20 Feb 2012 at 11:24

GoogleCodeExporter commented 9 years ago
Agreed. I'll try version 5.0.1.

Original comment by viljoe...@gmail.com on 20 Feb 2012 at 11:31