Erlang/OTP Forums

Author Message

<  RabbitMQ mailing list  ~  TCP timeout is also happening for C# clients

Guest
Posted: Tue May 13, 2008 9:55 pm Reply with quote
Guest
FYI: I have found that a Hearbeat adjustment solves a BasicPublish() timeout problem
in dotnet clients.

OK guys thanks for guidance with diagnosing the connection problems. It is solved
after I created an environment variable.

Now I progressed to the next problem (progress of sorts). But I bring a solution
too.

It all started when I called this line of code in my C# application:

mqModel.BasicPublish(mqTicket, mqExchange, mqRoutingKey, null,
builder.GetContentBody());

The following exception is always thrown by it:

"AMQP close-reason, initiated by Library, code=541, text=\"Unexpected Exception\",
classId=0, methodId=0, cause=System.IO.IOException: Unable to read data from the
transport connection: A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection failed
because connected host has failed to respond. --->
System.Net.Sockets.SocketException: A connection attempt failed because the
connected party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond\r\n at
System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size,
SocketFlags socketFlags)\r\n at System.Net.Sockets.NetworkStream.Read(Byte[]
buffer, Int32 offset, Int32 size)\r\n --- End of inner exception stack trace
---\r\n at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset,
Int32 size)\r\n at System.IO.Stream.ReadByte()\r\n at
System.IO.BinaryReader.ReadByte()\r\n at
RabbitMQ.Client.Impl.Frame.ReadFrom(NetworkBinaryReader reader)\r\n at
RabbitMQ.Client.Impl.SocketFrameHandler_0_9.ReadFrame()\r\n at
RabbitMQ.Client.Impl.ConnectionBase.MainLoopIteration()\r\n at
RabbitMQ.Client.Impl.ConnectionBase.MainLoop()"


So I looked around for solutions on the web, and discovered a "Java"-related
discussion recently in the mailing list:

http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2008-May/001183.html

The topic is TCP timeouts.

One possible solution to the "java" problem was proposed by manipulating the
heartbeat value of the connection factory:

http://www.rabbitmq.com/javadoc/com/rabbitmq/client/ConnectionParameters.html#setRequestedHeartbeat(int

But now I'm using C# rather than Java but the symptoms looked similar enough.

So I added a line of C# code to manipulate the heartbeat, just before it runs the
CreateConnection():

mqFactory.Parameters.RequestedHeartbeat = 50;

50 is a totally wild first guess but it actually works.

As a result of heartbeat modification my BasicPublish() call runs OK now. I dont
get the exception, and the code continues flowing in the preferred way.

I just want you all to know that by appearances this is not strictly a java specific
problem but the discussion seemed to assume it was limited to java clients, or
limited to the Sun company's products.

http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2008-May/001211.html

Excerpt: "A very interesting anomaly indeed, especially considering that it only
seems to affect 1.5, not 1.4 or 1.6. However, as far as I can tell this
behaviour can only occur with one CPU."

http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2008-May/001207.html

Actually I do have just one CPU core, it's true, but I do not code in java, just C#.

Here is what my log shows FWIW.

=INFO REPORT==== 13-May-2008::17:22:42 ===
Rolling persister log to "c:/Documents and
Settings/ga/rabbitmq/db/rabbit-mnesia/rabbit_persister.LOG.previous"

=INFO REPORT==== 13-May-2008::17:22:43 ===
started TCP listener on 0.0.0.0:5672

=INFO REPORT==== 13-May-2008::17:23:01 ===
accepted TCP connection on 0.0.0.0:5672 from 192.168.1.100:1551

=ERROR REPORT==== 13-May-2008::17:23:03 ===
error on TCP connection from 192.168.1.100:1551
connection_closed_abruptly

=INFO REPORT==== 13-May-2008::17:23:03 ===
closing TCP connection from 192.168.1.100:1551


I now suspect there is a threading bug in the RabbitMQ stack and it is common to
both C# and java clients either by repetition of a mistaken code pattern, or by some
code layer in the RabbitMQ system which is shared in common by clients of both
languages. Solutions applied in the application layer are probably not the best
way.


Hope this helps the knowledge base.


Geoffrey


_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
tonyg
Posted: Wed May 14, 2008 10:58 am Reply with quote
User Joined: 07 Nov 2006 Posts: 199
Hi Geoffrey,

Geoffrey Anderson wrote:
> FYI: I have found that a Hearbeat adjustment solves a BasicPublish() timeout problem
> in dotnet clients.

I think you may have happened across a bug others have seen before; are
you running .NET on a Microsoft operating system? If so, it is likely
that the Heartbeat feature will not work well for you, and you should
disable heartbeats by setting the heartbeat interval to zero.

See
http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2008-April/001043.html
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=94149

A future release of the RabbitMQ .NET client will employ an alternative
strategy for detecting idle sockets that does not fall foul of
Microsoft's broken read-timeout behaviour.

> OK guys thanks for guidance with diagnosing the connection problems. It is solved
> after I created an environment variable.

Great! Pleased to hear it.

> I now suspect there is a threading bug in the RabbitMQ stack and it is common to
> both C# and java clients either by repetition of a mistaken code pattern, or by some
> code layer in the RabbitMQ system which is shared in common by clients of both
> languages. Solutions applied in the application layer are probably not the best
> way.

I'd be surprised if you were seeing anything other than the
heartbeat-timeout problem.

Regards,
Tony
--
[][][] Tony Garnock-Jones | Mob: +44 (0)7905 974 211
[][] LShift Ltd | Tel: +44 (0)20 7729 7060
[] [] http://www.lshift.net/ | Email: tonyg@lshift.net

_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss@lists.rabbitmq.com
http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Post received from mailinglist
View user's profile Send private message MSN Messenger

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum