Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions projects/RabbitMQ.Client/client/api/ConnectionFactoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public static ITcpClient DefaultSocketFactory(AddressFamily addressFamily)
{
var socket = new Socket(addressFamily, SocketType.Stream, ProtocolType.Tcp)
{
NoDelay = true,
ReceiveBufferSize = 65536,
SendBufferSize = 65536
NoDelay = true
};
return new TcpClientAdapter(socket);
}
Expand Down
30 changes: 30 additions & 0 deletions projects/Unit/TestConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
//---------------------------------------------------------------------------

using System.Collections.Generic;
using System.Net.Sockets;
using RabbitMQ.Client.Exceptions;
using RabbitMQ.Client.Impl;
using Xunit;

namespace RabbitMQ.Client.Unit
Expand Down Expand Up @@ -69,6 +71,34 @@ public void TestProperties()
Assert.Equal(cf.Endpoint.MaxMessageSize, mms);
}

[Fact]
public void TestConnectionFactoryWithCustomSocketFactory()
{
const int bufsz = 1024;

ConnectionFactory cf = new()
{
SocketFactory = (AddressFamily af) =>
{
var socket = new Socket(af, SocketType.Stream, ProtocolType.Tcp)
{
SendBufferSize = bufsz,
ReceiveBufferSize = bufsz,
NoDelay = false
};
return new TcpClientAdapter(socket);
}
};

ITcpClient c = cf.SocketFactory(AddressFamily.InterNetwork);
Assert.IsType<TcpClientAdapter>(c);
TcpClientAdapter tcpClientAdapter = (TcpClientAdapter)c;
Socket s = tcpClientAdapter.Client;
Assert.Equal(bufsz, s.ReceiveBufferSize);
Assert.Equal(bufsz, s.SendBufferSize);
Assert.False(s.NoDelay);
}

[Fact]
public void TestCreateConnectionUsesSpecifiedPort()
{
Expand Down