如何解决Python 套接字:ConnectionAbortedError:[WinError 10053] 已建立的连接被主机中的软件中止
我正在尝试制作一个带有接收它的套接字的 twitch 机器人,但过了一会儿它超时了。我收到错误 ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine
这是我的代码(出于隐私原因,我用星号替换了 botnick、oauth 和 twitch 频道):
import time
import socket
import string
# change the stuff here
botnick = "***" #bot's nick.
oauth = "oauth:***" #oauth
twitch = "***" #your twitch channel
channel = twitch.lower() #thing i needed to do to make it connect to irc
##Sockets
sock = socket.socket()
def initialize():
sock.connect(('irc.chat.twitch.tv',6667))
time.sleep(0.1)
sock.send(f'PASS {oauth}\n'.encode('utf-8'))
time.sleep(0.1)
sock.send(f'NICK {botnick}\n'.encode('utf-8'))
time.sleep(0.1)
sock.send(f'JOIN #{channel}\n'.encode('utf-8'))
initialize()
def call():
resp = sock.recv(2048).decode('utf-8')
print(resp)
time.sleep(0.1)
if resp in "PING :tmi.twitch.tv":
sock.send(f'PONG\n'.encode('utf-8'))
Running = True
while Running == True:
call()
```
I can't find anything to help me that is relevant to what I am doing.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。