planetarium / libplanet

Blockchain in C#/.NET for on-chain, decentralized gaming
https://docs.libplanet.io/
GNU Lesser General Public License v2.1
506 stars 142 forks source link

Exception occurs when generating multiple swarms in SwarmTest #345

Closed limebell closed 4 years ago

limebell commented 5 years ago

I generated 20 swarms for each of 12 tests, exception occurs after passing 7 tests. All tests that failed throws following message.

테스트 이름: Libplanet.Tests.Net.SwarmTest.AsPeerThrowSwarmExceptionWhenUnbound
테스트 전체 이름:  Libplanet.Tests.Net.SwarmTest.AsPeerThrowSwarmExceptionWhenUnbound
테스트 소스: C:\Users\lime_\Documents\Planetarium\libplanet\Libplanet.Tests\Net\SwarmTest.cs : 줄 445
테스트 결과: 실패
테스트 지속 시간:  0:00:00.001

Result StackTrace:  
at NetMQ.Core.Ctx.CreateSocket(ZmqSocketType type) in C:\projects\netmq-2bhss\src\NetMQ\Core\Ctx.cs:line 269
   at NetMQ.NetMQSocket..ctor(ZmqSocketType socketType, String connectionString, DefaultAction defaultAction) in C:\projects\netmq-2bhss\src\NetMQ\NetMQSocket.cs:line 42
   at Libplanet.Net.Swarm`1..ctor(BlockChain`1 blockChain, PrivateKey privateKey, Int32 appProtocolVersion, TimeSpan dialTimeout, TimeSpan linger, String host, Nullable`1 listenPort, Nullable`1 createdAt, IEnumerable`1 iceServers, EventHandler`1 differentVersionPeerEncountered) in C:\Users\lime_\Documents\Planetarium\libplanet\Libplanet\Net\Swarm.cs:line 144
   at Libplanet.Net.Swarm`1..ctor(BlockChain`1 blockChain, PrivateKey privateKey, Int32 appProtocolVersion, Int32 millisecondsDialTimeout, Int32 millisecondsLinger, String host, Nullable`1 listenPort, Nullable`1 createdAt, IEnumerable`1 iceServers, EventHandler`1 differentVersionPeerEncountered) in C:\Users\lime_\Documents\Planetarium\libplanet\Libplanet\Net\Swarm.cs:line 97
   at Libplanet.Tests.Net.SwarmTest..ctor(ITestOutputHelper output) in C:\Users\lime_\Documents\Planetarium\libplanet\Libplanet.Tests\Net\SwarmTest.cs:line 58
Result 메시지: NetMQ.NetMQException : Exception of type 'NetMQ.NetMQException' was thrown.
longfin commented 5 years ago

Thanks for the report. It seems that NetMQSocket can't be created because there are too many opened socket already. I'll check NetMQConfig.Cleanup() in SwarmTest.Dispose().

limebell commented 5 years ago

During SwarmTest.Dispose(), I think StopAsync() should be applied to swarms that are running only.

if (s.Running)
{
    s.StopAsync().Wait(DisposeTimeout);
}