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 (将#修改为@)