Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Sending message from server to client when web socket is opened.

Open
#158 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python

Research direction

Start with the extended chat example and trace ChatWebSocketHandler.opened(), including the direct send and the websocket-broadcast publication. Check how the WebSocketPlugin pool handles a newly opened connection; done means a client receives the initial server message without the socket being terminated.

Written by the indexing model from the issue text.

Description

Gang:

I'm working with the extended chat example (works great out of the box), and trying to send a message from the server to the client when the web socket is initially opened:

    class ChatWebSocketHandler(WebSocket):
      def opened(self):
        cherrypy.engine.publish('add-client', self.username, self)
        self.send("Hello, World!")

However, this causes the web socket to be terminated. I've also tried publishing the message:

    class ChatWebSocketHandler(WebSocket):
      def opened(self):
        cherrypy.engine.publish('add-client', self.username, self)
        cherrypy.engine.publish("websocket-broadcast", "Hello, World!")

... which doesn't terminate the web socket, but doesn't send the message to the newly-connected client either (I assume this is because the broadcast is going out before the handler has been transferred to the WebSocketPlugin pool).

I'm looking to use web sockets for purely one-way publishing of a data feed from server to client(s), so this seems like a pretty basic use-case. What am I missing?

Thanks in advance,
Tim

Dominant language
Python
Stars
1.1k
Forks
286
Avg merge
1d 19h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.