Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection reset by peer #203

Closed
cozyGalvinism opened this issue May 6, 2016 · 7 comments
Closed

Connection reset by peer #203

cozyGalvinism opened this issue May 6, 2016 · 7 comments
Labels
invalid This is not right.

Comments

@cozyGalvinism
Copy link

cozyGalvinism commented May 6, 2016

I'm trying to write a music bot, but I get a ConnectionResetError most of the time.
The weird thing is: The bot connects, but throws this error, while the voice object stays empty.

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/discord/client.py", line 244, in _run_event
    yield from getattr(self, event)(*args, **kwargs)
  File "musicbot.py", line 21, in on_message
    voice = yield from client.join_voice_channel(message.author.voice_channel)
  File "/usr/local/lib/python3.4/dist-packages/discord/client.py", line 2454, in join_voice_channel
    yield from voice.connect()
  File "/usr/local/lib/python3.4/dist-packages/discord/voice_client.py", line 204, in connect
    self.ws = yield from DiscordVoiceWebSocket.from_client(self)
  File "/usr/local/lib/python3.4/dist-packages/discord/gateway.py", line 462, in from_client
    ws = yield from websockets.connect(gateway, loop=client.loop, klass=cls)
  File "/usr/local/lib/python3.4/dist-packages/websockets/client.py", line 150, in connect
    factory, wsuri.host, wsuri.port, **kwds)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 588, in create_connection
    sock, protocol_factory, ssl, server_hostname)
  File "/usr/lib/python3.4/asyncio/base_events.py", line 610, in _create_connection_transport
    yield from waiter
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/asyncio/selector_events.py", line 727, in _on_handshake
    self._sock.do_handshake()
  File "/usr/lib/python3.4/ssl.py", line 804, in do_handshake
    self._sslobj.do_handshake()
ConnectionResetError: [Errno 104] Connection reset by peer

The most important part of the code is this:

@client.event
@asyncio.coroutine
def on_message(message):
    if message.content == '!test':
        if message.author.voice_channel != None:
            voice = yield from client.join_voice_channel(message.author.voice_channel)
            player = yield from voice.create_ytdl_player('https://www.youtube.com/watch?v=HjuNJA4RO-k', after=dc())
            player.start()
    elif message.content == '!dc':
        voice.disconnect()

What's more weird is, that reconnecting doesn't work either.
Is this an error on my side, or is there a workaround?

@AraHaan
Copy link

AraHaan commented May 9, 2016

there shoudl be try somethign like this https://gist.github.com/yyli/6d01699a0fe8a52e7719

@cozyGalvinism
Copy link
Author

Same happens again... Could it be, that the SSL module is just refusing to work properly? Atm, I have to open the bot, let it connect to a voice channel (which throws the error), stop the bot, run it again and then it works.

Either it's something with my server or with the SSL module (because of self._sslobj.do_handshake() in the log). I'll check, if I can find any issue on my server, but I doubt it, since on the 2nd try, it works without problems...

@AraHaan
Copy link

AraHaan commented May 9, 2016

Yeah I say its the python libs that discord.py runs on when I compied them to a folder and inspected it with PyCharm it did come up with over 2,000 errors (most of them being from PEP8) and others as well.

@cozyGalvinism
Copy link
Author

Weird... I guess we'll have to wait then... maybe the libs aren't fully working with 3.5 yet (I was only able to install Python3.5 using a dirty workaround on Debian). Oh well... I guess there's no workaround then...

I don't mind restarting it after starting it and letting it fail, it's just annoying

@imayhaveborkedit
Copy link
Contributor

I don't know what a "dirty workaround" to install python3.5 on debian is supposed to mean, but compiling software that's not in the repos is standard for linux. The lib has worked with 3.5 since the async rewrite happened. Its not a lib issue or a python version issue. Connection Reset is a network error. It would happen with either version python. Voice works perfectly fine for my bot and most other people who use the lib. Something between you and the discord servers is causing an issue.

@cozyGalvinism
Copy link
Author

"Dirty workaround" because I couldn't build Python3.5 on my server. So I had to take already compiled binaries from a 3rd party source.

Also, I checked the firewall of my server and opened the ports for Discord -> Same result

@Rapptz Rapptz added the invalid This is not right. label May 12, 2016
@Rapptz Rapptz closed this as completed May 12, 2016
@hanss314
Copy link

It's closed and marked as invalid. I don't think there is a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This is not right.
Projects
None yet
Development

No branches or pull requests

5 participants