[rabbitmq-discuss] SocketException when invoking model.BasicPublish

Scott McFadden scott.kendall.mcfadden at gmail.com
Thu Jun 19 04:00:04 BST 2014

Thanks for the suggestion Michael.  I checked at there is no sharing of the
connection across the thread.  The connection is all self contained to this
method and this method is only invoked once on the thread.  The odd thing
is that this same client code used to work.  It quit working when our
rabbit mq server hyper-v image snapshot got rolled back and I had to
re-install reconfigure rabbit mq.  It makes me think I screwed up the
server side configuration when reinstalling.

private void PublishMessage(byte[] message, Type messageType, string
contentType, string messageId)
            var factory = new ConnectionFactory() {VirtualHost =
this.VirtualHost, HostName = this.Host, UserName = this.User, Password =
this.Password };
            using (var connection = factory.CreateConnection())
            using (var channel = connection.CreateModel())
                IBasicProperties props = channel.CreateBasicProperties();

                //Mime time
                props.ContentType = contentType;
                props.Type = messageType.FullName;
                props.MessageId = messageId;


                //Note, may get AlreadyClosedException here if publishing
to a incorrect exchange name
                channel.BasicPublish(this.ExchangeName, this.RoutingKey,
props, message);

On Wed, Jun 18, 2014 at 9:04 PM, Michael Klishin <mklishin at gopivotal.com>

> On 19 June 2014 at 06:02:28, Scott McFadden (
> scott.kendall.mcfadden at gmail.com) wrote:
> > > =ERROR REPORT==== 18-Jun-2014(
> http://airmail.calendar/2014-06-18%2012:00:00%20GMT+4)::20:17:08
> > ===
> > AMQP connection <0.473.0> (running), channel 1 - error:
> > {amqp_error,unexpected_frame,
> > "expected content header for class 60, got non content header
> > frame instead",
> > 'basic.publish'}
> This looks like a well known issue you'll run into if you share a channel
> (IModel) between
> threads, in particular threads that publish messages. This is a
> connection-level error,
> so after getting it RabbitMQ closes the connection and your get socket
> errors on any subsequent
> operation in the client.
> Can the cross-thread sharing be the case?
> --
> MK
> Software Engineer, Pivotal/RabbitMQ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140618/baa94e21/attachment.html>

More information about the rabbitmq-discuss mailing list