Discord.Net: Discord.net 0.9.5 + Mono - An address incompatible with the requested protocol was used

The bot works very well on my Windows machine, but when I tried to migrate it to a Linux server, it built fine, but when I start it, I get the following exception:

Log 10/2/2016 7:19:48 PM: GET voice/regions: 401.86 ms
Log 10/2/2016 7:19:48 PM: GET gateway: 22.95 ms
Log 10/2/2016 7:19:48 PM: Login successful, gateway: wss://gateway.discord.gg/?encoding=json&v=4
Crashed with exception, restarting.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Sockets.SocketException: An address incompatible with the requested protocol was used
  at System.Net.Sockets.Socket..ctor (System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType) [0x0005d] in <6c7c03f48a9747c8a644da4f63a34480>:0
  at System.Net.Sockets.Socket.ConnectAsync (System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType, System.Net.Sockets.SocketAsyncEventArgs e) [0x0000b] in <6c7c03f48a9747c8a644da4f63a34480>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00038] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
   --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00053] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at SuperSocket.ClientEngine.ConnectAsyncExtension.ConnectAsync (System.Net.EndPoint remoteEndPoint, SuperSocket.ClientEngine.ConnectedCallback callback, System.Object state) [0x00039] in <4ba236fbf29248a4985a92e6e3907e4a>:0
  at SuperSocket.ClientEngine.TcpClientSession.Connect () [0x00074] in <4ba236fbf29248a4985a92e6e3907e4a>:0
  at WebSocket4Net.WebSocket.Open () [0x0003a] in <4ba236fbf29248a4985a92e6e3907e4a>:0
  at Discord.Net.WebSockets.WS4NetEngine.Connect (System.String host, System.Threading.CancellationToken cancelToken) [0x000cc] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at Discord.Net.WebSockets.WebSocket+<BeginConnect>d__34.MoveNext () [0x003b7] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at Discord.Net.WebSockets.GatewaySocket+<Connect>d__12.MoveNext () [0x0013f] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () [0x00351] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () [0x005a6] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at Discord.DiscordClient+<Connect>d__77.MoveNext () [0x0008b] in <599fbedd978e4fce934746a63a740a87>:0
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0004e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at System.Runtime.CompilerServices.TaskAwaiter.GetResult () [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
  at PlaneSculptorsDiscordBot.Program+<Main>c__AnonStorey7+<Main>c__async6.MoveNext () [0x00085] in <a353675f20fb49b8b7b05a5467a7fc40>:0

You can find source code of the bot here: https://github.com/mzabsky/webdrafter/tree/master/bot/PlaneSculptorsDiscordBot

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Exactly the same problem. Imported certs and using 4.6.1 mono.

Update: The problem seems to be mono itself. Downgrading from 4.6.1 to 4.4.2 fixes the issue instantly. If anyone is having this issue, looks like the temporary workaround is to just downgrade mono.