Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Page:  1  2  next
Avatar
svenk #1
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Subject: object reference not set in ClientSocket.EndSend
Hi,

In my project there is requirement to have multiple MUC rooms. Each room signifies a data that comes from a equipment.
There is a component (called Writer) that reads the data from multiple equipments and writes to the data to the respective rooms from multiple threads. There are client components that listen to the data from mostly all the room.

I've encountered few problems - the significant one is the object reference exception in ClientSocket.EndSend method.

The other problems I've received are in the MessageGrabber when the client component registers (from multiple threads) a callback, there is exception saying the enumeration is modified in another thread. I solved it by adding a lock in the registration code.  I suggest that the MessageGrabber.Add and Remove methods be locked...

Is the library production ready? I see a lot of Console.WriteLine in the library code... Should I wait for a newer version?
Avatar
Jabberer #2
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
Quote by svenk:
In my project there is requirement to have multiple MUC rooms. Each room signifies a data that comes from a equipment.
There is a component (called Writer) that reads the data from multiple equipments and writes to the data to the respective rooms from multiple threads. There are client components that listen to the data from mostly all the room.

I've encountered few problems - the significant one is the object reference exception in ClientSocket.EndSend method.

The other problems I've received are in the MessageGrabber when the client component registers (from multiple threads) a callback, there is exception saying the enumeration is modified in another thread. I solved it by adding a lock in the registration code.  I suggest that the MessageGrabber.Add and Remove methods be locked...

can you please attach your patch/changes or a test case which causes this problems?

Can you post more details about the ClientSocket.EndSend exception? Did you try to lock the Send method? But normally the socket is thread safe, however we had some threading problems before with the SslStream.

Quote by svenk:
Is the library production ready? I see a lot of Console.WriteLine in the library code... Should I wait for a newer version?

yes the library is production ready. We can remove the Console Output if it disturbs you or add some defines. But it does not affect the release version
Software Developer
AG-Software
Avatar
svenk #3
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Quote by Jabberer:
can you please attach your patch/changes

The patch on the MessageGrabber.cs will be:

public void Add(Jid jid, MessageCB cb, object cbArg)
{
    lock (this)
    {
    // ... the older code in the fn
    }
}

public void Add(Jid jid, IComparer comparer, MessageCB cb, object cbArg)
{
    lock (this)
    {
    // the older code in the fn
    }
}

public void Remove(Jid jid)
{
    lock (this)
    {
    // the older code in the fn
    }
}

Quote by Jabberer:
Can you post more details about the ClientSocket.EndSend exception? Did you try to lock the Send method? But normally the socket is thread safe, however we had some threading problems before with the SslStream.

No I haven't tried to lock the send method. In fact I haven't modified any code in the library. How do I send the code? I have a helper and the actual test code.
Avatar
Jabberer #4
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
i will make all the Grabber classes thread safe by locking only the code which adds/removes objects on th Hashtables.
Alex will checkin this code to SVN tonight then.

You can add attachments to your posts (max 500 kB).
Software Developer
AG-Software
Avatar
svenk #5
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
agsXmppHelper.zip is a utility library. Used mainly to to perform login, logoff as a synchronous call.
agxmppWriter.zip creates tasks to be thrown into a task framework to be executed in a thread pool.
agxmppTest.zip reads the data from the rooms in multiple threads. This project does not reply at all!!!

I get object reference exception in-deterministically from the writer project!!!
The author has attached one file to this post:
ToPost.zip 59.2 kBytes
You have no permission to open this file.
Avatar
Alex #6
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Hello,

added thread safety to MessageGrabber and PrecenceGrabber. The new code is in SVN. Can you please check it out and confirm if it works?

I will take a look at your attachment now.

Alex
Avatar
Alex #7
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
there are many 3rd party libraries missing in your attachment.

  • ProxyObjects
  • TaskFrameWork
  • Utilities

Alex
Avatar
svenk #8
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
The 3rd party libraries cannot be given. please create stubs / mocks for them....
ProxyObjects - collection of types that are serializable. The FetalData is a type that is defined in this assembly.
TaskFrameWork - threading utility.
Utilities - helpers to serialize.

Thanks
Venky
Avatar
svenk #9
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Modified the project to strip off the dependencies and created a stub myself. So you got the new zip... ignore the previous one. Any help in finding the bug is really appreciated.

Thanks for all the help and patience!!
The author has attached one file to this post:
ToPost.zip 82 kBytes
You have no permission to open this file.
Avatar
svenk #10
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Sorry about a small glitch. The app.config in both the writer and the test project should have the following line instead of the older one.

<section name="ThreadPoolConfiguration" type="TaskFramework.ThreadPoolConfiguration, TaskFramework" />

Apologies once again
Avatar
svenk #11
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
Some more info on the stack trace...
 
 at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Collections.Queue.SetCapacity(Int32 capacity)
   at System.Collections.Queue.Enqueue(Object obj)
   at agsXMPP.net.ClientSocket.Send(Byte[] bData) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\net\ClientSocket.cs:line 544
   at agsXMPP.net.ClientSocket.Send(String data) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\net\ClientSocket.cs:line 515
   at agsXMPP.XmppConnection.Send(String xml) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\XmppConnection.cs:line 310
   at agsXMPP.XmppConnection.Send(Element e) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\XmppConnection.cs:line 322
   at Com.GeHciits.Cpn.agsXmppHelper.MultiUserChat.sendMessage(String msgText) in D:\cpn_source\70_xmpp\QS\CPN\dotnetsrc\common\agsXmppHelper\MultiUserChat.cs:line 47
   at agxmppWriter.MonitorTask.execute() in D:\Venkwork\personal\mytests\agxmppWriter\MonitorTask.cs:line 54
   at TaskFramework.Task.run() in D:\Venkwork\personal\TransDump\src\common\utils\TaskFrameWork\Task.cs:line 89
   at TaskFrameWork.Threading.ThreadPoolWorkItem.invoke() in D:\Venkwork\personal\TransDump\src\common\utils\TaskFrameWork\CustomThreadPool\ThreadPoolWorkItem.c
s:line 128
   at TaskFramework.Threading.CustomThreadPool.executeWorkItem(ThreadPoolWorkItem job) in D:\Venkwork\personal\TransDump\src\common\utils\TaskFrameWork\CustomThreadPool\CustomThreadPool.cs:line 729

This exception stack was there in every thread when trying to send.

When I tried to close the application by sending a presense message, I again got the following....
System.ArgumentException: Source array was not long enough.
 Check srcIndex and length, and the array's lower bounds.
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Collections.Queue.SetCapacity(Int32 capacity)
   at System.Collections.Queue.Enqueue(Object obj)
   at agsXMPP.net.ClientSocket.Send(Byte[] bData) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\net\ClientSocket.cs:line 544
   at agsXMPP.net.ClientSocket.Send(String data) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\net\ClientSocket.cs:line 515
   at agsXMPP.XmppConnection.Send(String xml) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\XmppConnection.cs:line 310
   at agsXMPP.XmppClientConnection.KeepAliveTick(Object state) in D:\Venkwork\personal\downloads\agSoftware\agsxmpp\XmppClientConnection.cs:line 1238
   at System.Threading._TimerCallback.TimerCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading._TimerCallback.PerformTimerCallback(Object state)

Any help is appreciated
Avatar
Jabberer #12
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
hello svenk,

we have lots of meetings this morning. But we will look at your code in the afternoon or tomorrow.

Just a quick idea:
can you try to make the SendQueue (m_SendQueue) in ClientSocket.cs thread safe with locks?
Software Developer
AG-Software
Avatar
Jabberer #13
Member since Feb 2006 · 249 posts
Group memberships: Members
Show profile · Link to this post
or lock the whole Send function for a test
Software Developer
AG-Software
Avatar
svenk #14
User title: Mr.
Member since Jul 2007 · 9 posts
Group memberships: Members
Show profile · Link to this post
I did the changes to the ClientSocket.cs  - send related methods and god it is working without any exception till now (4 hrs now).... though the receive sometimes gives object reference issue for the first time and behaves ok after that.

I'm attaching the file.
The author has attached one file to this post:
ClientSocket.cs 21.7 kBytes
You have no permission to open this file.
Avatar
Alex #15
Member since Feb 2003 · 4317 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
cool then we located the problem.
I will make the changes and checkin the code to SVN ASAP.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Page:  1  2  next
Forum: agsXMPP RSS