Skip to content

When multiple processes are started, duplicate ports will be bound #115

@realLiangshiwei

Description

@realLiangshiwei

The rider can set the number of assemblies in parallel, when multiple processes get available ports, mong2go get duplicate ports and throw an exception

image

MongoDB.Driver.MongoCommandException
Command replSetInitiate failed: already initialized.
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId connectionId, CommandMessage responseMessage)
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1.Execute(IConnection connection, CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`1 protocol, ICoreSession session, CancellationToken cancellationToken)

So, in multi-process, we cannot be sure that the port is available.

public bool IsPortAvailable(int portNumber)

Use a port number of zero if you want the underlying service provider to assign a free port for you

https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socket?view=net-5.0#remarks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions