I'm trying to get a discord bot coded in discord.net running on a linux VPS, I'm running via mono but I keep getting this error
Unhandled Exception:
System.Exception: Connection lost
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at Discord.TaskManager.ThrowException () <0x419160b0 + 0x00065> in <filename unknown>:0
at Discord.Net.WebSockets.WebSocket.WaitForConnection (CancellationToken cancelToken) <0x4192a2a0 + 0x000af> in <filename unknown>:0
at Discord.Net.WebSockets.GatewaySocket.WaitForConnection (CancellationToken cancelToken) <0x4192a1b0 + 0x000c3> in <filename unknown>:0
at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () <0x41836df0 + 0x01406> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () <0x41836df0 + 0x01abe> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () <0x7f0ad7fffb10 + 0x00012> in <filename unknown>:0
at Discord.DiscordClient+<Connect>d__77.MoveNext () <0x41836560 + 0x002b1> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7f0ad7fff5c0 + 0x00012> in <filename unknown>:0
at MiXBot.Program+<>c+<<Main>b__1_3>d.MoveNext () <0x41835e40 + 0x001bd> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7f0ad7fff5c0 + 0x00012> in <filename unknown>:0
at Discord.DiscordClient.ExecuteAndWait (System.Func`1 asyncAction) <0x41835b00 + 0x00086> in <filename unknown>:0
at MiXBot.Program.Main (System.String[] args) <0x417fbf60 + 0x002a3> in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.Exception: Connection lost
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at Discord.TaskManager.ThrowException () <0x419160b0 + 0x00065> in <filename unknown>:0
at Discord.Net.WebSockets.WebSocket.WaitForConnection (CancellationToken cancelToken) <0x4192a2a0 + 0x000af> in <filename unknown>:0
at Discord.Net.WebSockets.GatewaySocket.WaitForConnection (CancellationToken cancelToken) <0x4192a1b0 + 0x000c3> in <filename unknown>:0
at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () <0x41836df0 + 0x01406> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at Discord.DiscordClient+<BeginConnect>d__78.MoveNext () <0x41836df0 + 0x01abe> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwaiter.GetResult () <0x7f0ad7fffb10 + 0x00012> in <filename unknown>:0
at Discord.DiscordClient+<Connect>d__77.MoveNext () <0x41836560 + 0x002b1> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7f0ad7fff5c0 + 0x00012> in <filename unknown>:0
at MiXBot.Program+<>c+<<Main>b__1_3>d.MoveNext () <0x41835e40 + 0x001bd> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () <0x7f0ad80016d0 + 0x00029> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) <0x7f0ad7fff6b0 + 0x000a7> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) <0x7f0ad7fff630 + 0x0006b> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) <0x7f0ad7fff5e0 + 0x0003a> in <filename unknown>:0
at System.Runtime.CompilerServices.TaskAwaiter.GetResult () <0x7f0ad7fff5c0 + 0x00012> in <filename unknown>:0
at Discord.DiscordClient.ExecuteAndWait (System.Func`1 asyncAction) <0x41835b00 + 0x00086> in <filename unknown>:0
at MiXBot.Program.Main (System.String[] args) <0x417fbf60 + 0x002a3> in <filename unknown>:0
I have mono and .net core installed and I'm running it through mono.
Any suggestions? (I'd like to stick with discord.net if possible)
I'm just going to take a stab at the solution because I didn't see you mention that you installed dotnet core on linux. Here is a guide that has a checklist to follow your steps to make sure it's working correctly. Discord.net appears to be in .net core.
If it still fails after that, try running other .net core apps on your linux server and see if those work. I hope this helps!
https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x
I'm going to assume due to lack of context that you built your application using
.Net Framework
to which I can recommend you switch to.Net Core
.Afterwhich as mentioned by Solarcloud ensure you have
Dotnet Core
installed on your Linux box and then you can simply run it bydotnet MyApplication.dll
after you build it, navigate to the folder etc.