断线重连怎么做?

Open
#237 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
15/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

The issue only shows a WebSocketClient example using connect(), run_forever(), opened(), and closed(). Start by reviewing those entry points and the library's client implementation; the issue does not name a file or test. A useful completion criterion would require the desired reconnection behavior and affected API to be specified first.

Written by the indexing model from the issue text.

Description

from ws4py.client.threadedclient import WebSocketClient
from ws4py.exc import HandshakeError
class DummyClient(WebSocketClient):
def opened(self):
self.send(input('请输入你想说的话:'))

def closed(self, code, reason=None):
    #print("Closed down", code, reason)
    print("Closed down")


def received_message(self, m):
    print (m)

if name == 'main':
try:
ws = DummyClient('ws://'+input('请输入ws地址连接:'), protocols=['chat'])
ws.connect()
ws.run_forever()
except KeyboardInterrupt:
ws.close()

Dominant language
Python
Stars
1.1k
Forks
285
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Lawouach/WebSocket-for-Python

All issues in Lawouach/WebSocket-for-Python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.