Skip to content

Instantly share code, notes, and snippets.

@leduyquang753
Last active November 4, 2024 09:13
Show Gist options
  • Save leduyquang753/457ad629dbba82e5e30a87f08b4ac044 to your computer and use it in GitHub Desktop.
Save leduyquang753/457ad629dbba82e5e30a87f08b4ac044 to your computer and use it in GitHub Desktop.
Simple game buzzer system for PowerPoint
/* KEY GENERATOR – NodeJS
Replace the strings with the keys you want and run with NodeJS.
It will generate the hashes for you to install into the server script.
Copyright © 2019 Le Duy Quang. Licensed under MIT.
*/
const inputStrings = ["Lorem ipsum","dolor sit amet"]; // Input strings.
const shaUtil = require('js-sha256');
String.prototype.hashCode = function() {
return shaUtil(String(this));
};
inputStrings.forEach((s, i) => {console.log(s + ' ' + s.hashCode());});

PowerPoint buzzer

This is a small game buzzer system for use with PowerPoint and smartphones. It can be completely customized to your own needs.

Overview

The system makes use of multiple platforms:

  • NodeJS for server hosting: server.js.
  • Web for clients: sender.html.
  • Python for receiving signals: receiver.py.
  • Visual Basic for applications (VBA) for interactions with PowerPoint.

It turns any smartphones with a modern browser into a live game buzzer, activated simply by touching the screen.

Setup instructions

Set up platforms

  • NodeJS: Install ws and js-sha256.
  • Python: Install pywin32 and websockets.
  • Web: Install and configure any functional HTML web server.
  • PowerPoint: Enable the VBA feature.

Generate client keys

  1. Generate and place client keys into getHash.js to retrieve their hashes. Client keys are simply any strings of text.
  2. Place the hashes into server.js accordingly.
  3. Place the receiver's client key into receiver.py.

Run the server

  1. Set the server's port in server.js.
  2. Set the server's address in receiver.py and sender.html.
  3. Run server.js using NodeJS.

Note: If you are planning to use the system in the local network, you can check your computer's IP address in Task manager → Performance → Network. Other devices in the same network can access your server through that IP.

Run the receiver

  1. Open Buzzers test.pptm. Enable its macro contents, they are safe and do not control anything outside of the PowerPoint presentation itself. You can feel free to check if you want to be absolutely sure.
  2. Put a sound file named buzzer.wav (or another name as long as you change it accordingly in receiver.py) into receiver.py's folder. This sound will be played when a buzzer is activated.
  3. Run receiver.py.

Setup buzzer devices

  1. Put sender.html into your web server. You can rename it, for example to index.html for easy access.
  2. Get any device with a modern browser and if you plan to run in a local network, connect it to the same network as your server.
  3. Use the browser to access sender.html in your web server.
  4. If the screen is red, the device failed to connect to the NodeJS server; fix the problem and reload the page. If it is yellow, it has successfully connected; enter the client key as instructed on the screen. If the screen turns green, then you can proceed to the next steps.
  5. Repeat steps 2; 3 and 4 to connect more buzzers.
  6. Put the PowerPoint presentation into slide show mode. Click the Reset button. Try activating a buzzer. If the buzzer's corresponding slot lights up and the buzzer sound plays, then you have set up everything correctly.

Setup for your own PowerPoint presentation

The Buzzers test.pptm presentation, as the name suggests, acts as a test, but you can use it in production. If you want to implement it into your own presentation, here is how:

  1. In a slide, create shapes named "Team 1 buzzer", "Team 2 buzzer",... "Team n buzzer", where n is the number of buzzers you want.
  2. Copy and paste the VBA code from VBACode.vb into a VBA module in your presentation.
  3. To reset the system, run the macro BuzzersResetAll. You can link an action button to it.
  4. Perform similarly to Setup buzzer devices to test the system.

Operation

When a buzzer is activated, the corresponding slot will change color and the sound will play. From that point until the system is reset, activating buzzers won't do anything, thus in a race, only the quickest gets the chance/point.

License

The MIT license

Copyright © 2019 Le Duy Quang.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "software"), to deal in the software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, and to permit persons to whom the software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the software.

The software is provided as is, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

""" BUZZER SIGNAL RECEIVER – Python
Required external modules:
– pywin32
– websockets
When running, be sure to have the presentation opened and VBA loaded.
Copyright © 2019 Le Duy Quang. Licensed under MIT.
"""
serverAddress = 'ws://localhost:2909' # The server's address.
clientKey = 'Y*!TTGBg7t1hhh$T&g@*T@*(THBhGiwiohoiu2^*(^' # The client key corresponding to the receiver's hash.
buzzerSoundFile = 'buzzer.wav' # The name/path of the buzzer sound file.
import asyncio
import websockets
from win32com.client import Dispatch
import winsound
from threading import Thread
app = Dispatch('PowerPoint.Application')
def playBuzzerSound():
global buzzerSoundFile
winsound.PlaySound(buzzerSoundFile, winsound.SND_FILENAME+winsound.SND_ASYNC)
async def mainFunction():
global serverAddress, clientKey
async with websockets.connect(serverAddress) as ws:
await ws.send('PASSWORD: ' + clientKey)
while True:
msg = await ws.recv()
if msg.startswith('BUZZER '):
if app.Run('onBuzzerActivated', int(msg[7:])):
Thread(target=playBuzzerSound).start();
asyncio.get_event_loop().run_until_complete(mainFunction())
<!--
BUZZER BUTTON CLIENT – HTML
Runs out of the box on any modern browser. The whole screen is the button.
Copyright © 2019 Le Duy Quang. Licensed under MIT.
-->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Buzzer</title>
<style>
#settingsButton {
background-color: RGBA(0,0,0,0.05);
bottom: 0px;
left: 0px;
width: 10%;
height: 10%;
position: absolute;
}
#notifications {
position: absolute;
top: 0px;
left: 0px;
width: 100%;
font-family: Segoe UI, Arial, sans-serif;
font-size: 1em;
text-align: center;
}
#buzzerArea {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id=buzzerArea hidden></div>
<div id=settingsButton onclick="enterPassword(event)" hidden></div>
<div id=notifications></div>
<script>
const serverAddress = 'ws://localhost:2909'; // The server's address.
function enterPassword(event) {
event.preventDefault();
ws.send('PASSWORD: '+prompt('Enter the client key:'));
}
function sendBuzzer(event) {
ws.send('BUZZER');
}
var ws = new WebSocket(serverAddress);
var notif = document.getElementById('notifications');
var buzzerArea = document.getElementById('buzzerArea');
var settingsButton = document.getElementById('settingsButton');
document.getElementById('buzzerArea').addEventListener('click', sendBuzzer);
ws.onerror = function() {
document.bgColor = '#FFA5A5';
notif.style.color = '#600000';
notif.innerHTML = '<b>ERROR:</b> Failed to connect to the server.<br/>Please contact the operator and reload this page when the issue has been fixed.';
};
ws.onopen = function() {
document.bgColor = '#FFF1A2';
notif.style.color = '#806C00';
notif.innerHTML = "This device has connected to the server but is not yet authenticated.<br/>Tap the lower-left corner of the screen to enter the client key in order to connect.";
settingsButton.hidden = false;
ws.onclose = function() {
document.bgColor = '#FFA5A5';
notif.style.color = '#600000';
notif.innerHTML = '<b>ERROR:</b> Server connection has been interrupted.<br/>Please contact the operator and reload this page when the issue has been fixed.';
buzzerArea.hidden = true;
settingsButton.hidden = true;
document.removeEventListener('keypress', sendBuzzer);
};
};
ws.onmessage = function(msg) {
if (msg.data == 'CONNECTED SUCCESSFULLY') {
document.bgColor = '#BCFFA9';
notif.innerHTML = '';
buzzerArea.hidden = false;
document.addEventListener('keypress', sendBuzzer);
}
};
</script>
</body>
</html>
/* BUZZER SERVER SCRIPT – NodeJS
Required external libraries:
– ws
– js-sha256
Copyright © 2019 Le Duy Quang. Licensed under MIT.
*/
const WebSocket = require('ws');
const shaUtil = require('js-sha256');
String.prototype.hashCode = function() {
return shaUtil(String(this));
};
const server = new WebSocket.Server({port:2909}); // Change to another port if you like.
// Hashes of client keys. Generate them using getHash.js and place them here.
const passes = {
'5eaa7a23eeb4ee86c30ec40dabe1e28f858342b2c83a92ffdcc735035511b68b': 0, // Receiver's key.
'40144db4eddf4c7ebef6629de3442f66bab5899e5f6bd308cd30919f16ae4963': 1, // Buzzer #1's key.
'9c339dbba7919d475985543e53b136e6d54a2ee3d1af5f0748566b060144dd69': 2, // Buzzer #2's key...
'7d43b0053a9da7b83b321cd461646c3dec646cb3fa45374f86cbebfb2ea43736': 3,
'ac1ead30257f32bf02ea5dff55597b6c525d8626d2799c6b2b9650387bb914da': 4
};
var receiver = null;
var senders = {1: null, 2: null, 3: null, 4: null}; // You can add more/remove buzzers if you want to.
const lockClients = true; // If it is true, a connected client will not be overriden by another client logging in until it disconnects.
if (lockClients) canConnect = function(id) {
if (id == 0) return receiver === null;
return senders[id] === null;
}
else canConnect = function(id) {
return true;
}
function processBuzzer(client) {
if (receiver == null) return;
receiver.send('BUZZER '+client.buzzerId);
//console.log('Buzzer #'+client.buzzerId+' is activated.');
}
function onDisconnect(id) {
if (id === 0) {
receiver = null;
console.log('Receiver has disconnected.');
} else {
senders[id] = null;
console.log('Sender #' + id + ' has disconnected.');
}
}
server.on('connection', function(client) {
client.sendBuzzer = function() {};
client.on('message', function(message) {
if (message.startsWith('PASSWORD: ')) {
let id = passes[message.substring(10).hashCode()];
if (id !== undefined && canConnect(id)) {
if (client.buzzerId !== undefined) onDisconnect(client.buzzerId);
client.buzzerId = id;
if (id === 0) {
receiver = client;
console.log('Receiver has connected.');
} else {
senders[id] = client;
console.log('Sender #' + id + ' has connected.');
client.sendBuzzer = function() { processBuzzer(this) };
client.send('CONNECTED SUCCESSFULLY');
}
}
}
if (message == 'BUZZER') client.sendBuzzer();
});
client.on('close', function() {
if (client.buzzerId !== undefined) onDisconnect(client.buzzerId);
});
});
console.log('Server is running.');
Const slideNumber As Integer = 1 ' The slide number in your presentation.
Dim shouldAcceptBuzzers As Boolean
Dim theSlide As Slide
Sub BuzzersResetAll()
Set theSlide = ActivePresentation.Slides(1)
Dim i As Integer
For i = 1 To 4
theSlide.Shapes("Team " + CStr(i) + " buzzer").Fill.ForeColor.RGB = 16777215
Next i
shouldAcceptBuzzers = True
End Sub
Function onBuzzerActivated(ByVal team As Integer)
If Not shouldAcceptBuzzers Then
onBuzzerActivated = False
Exit Function
End If
theSlide.Shapes("Team " + CStr(team) + " buzzer").Fill.ForeColor.RGB = 9306037
shouldAcceptBuzzers = False
onBuzzerActivated = True
End Function
@leduyquang753
Copy link
Author

Hello, i have a problem with connecting to the server.....what do i make wrong ? The Receivers client id is "Master"....this is what a typed in the receiver.py.....is this right ?? Is it right to only double-clicking the receiver.py ?? SO I'm very happy for any help !!

Thanks Steven

You should run the server and receiver scripts in a terminal to be aware of any errors that occur.

@StevenRott
Copy link

So which terminal I should use and how ? The server is running but the webside is red......

@leduyquang753
Copy link
Author

So which terminal I should use and how ? The server is running but the webside is red......

Any terminal works. You just use the command line interface to run the scripts and be able to see their output.

Check if you have set the correct server address and the server is accessible through the network.

@StevenRott
Copy link

OKay.....i have the feeling I don't understand anything !!:-(
I've the server.js in C:\Users\Steven\node_modules and started it with "node server.js" in the node command prompt.
The receiver.py is saved in C:\Python310\Lib an i started it with the anaconda terminal with "python receiver.py" an i git the following fault:

(base) C:\Python310\Lib>python receiver.py
Traceback (most recent call last):
File "receiver.py", line 16, in
import asyncio
File "C:\Python310\Lib\asyncio_init
.py", line 8, in
from .base_events import *
File "C:\Python310\Lib\asyncio\base_events.py", line 18, in
import concurrent.futures
File "C:\Python310\Lib\concurrent\futures_init_.py", line 8, in
from concurrent.futures.base import (FIRST_COMPLETED,
File "C:\Python310\Lib\concurrent\futures_base.py", line 7, in
import logging
File "C:\Python310\Lib\logging_init
.py", line 26, in
import sys, os, time, io, re, traceback, warnings, weakref, collections.abc
File "C:\Python310\Lib\re.py", line 336, in
import copyreg
File "C:\Python310\Lib\copyreg.py", line 43, in
pickle(type(int | str), pickle_union)
TypeError: unsupported operand type(s) for |: 'type' and 'type'_

If I started this in node-modules, there is the fault, that websockets is not available.....

Did I do everything wrong ?? SO can you help me please ?? :-))

Greets Steven

@leduyquang753
Copy link
Author

leduyquang753 commented Nov 9, 2021

OKay.....i have the feeling I don't understand anything !!:-( I've the server.js in C:\Users\Steven\node_modules and started it with "node server.js" in the node command prompt. The receiver.py is saved in C:\Python310\Lib an i started it with the anaconda terminal with "python receiver.py" an i git the following fault:

(base) C:\Python310\Lib>python receiver.py Traceback (most recent call last): File "receiver.py", line 16, in import asyncio File "C:\Python310\Lib\asyncio__init_.py", line 8, in from .base_events import * File "C:\Python310\Lib\asyncio\base_events.py", line 18, in import concurrent.futures File "C:\Python310\Lib\concurrent\futures__init__.py", line 8, in from concurrent.futures.base import (FIRST_COMPLETED, File "C:\Python310\Lib\concurrent\futures_base.py", line 7, in import logging File "C:\Python310\Lib\logging__init_.py", line 26, in import sys, os, time, io, re, traceback, warnings, weakref, collections.abc File "C:\Python310\Lib\re.py", line 336, in import copyreg File "C:\Python310\Lib\copyreg.py", line 43, in pickle(type(int | str), pickle_union) TypeError: unsupported operand type(s) for |: 'type' and 'type'_

If I started this in node-modules, there is the fault, that websockets is not available.....

Did I do everything wrong ?? SO can you help me please ?? :-))

Greets Steven

It appears you are having issues with your installed Python modules. Try upgrading asyncio and its dependencies or doing a fresh reinstall.

@StevenRott
Copy link

StevenRott commented Nov 9, 2021 via email

@StevenRott
Copy link

Okay...no pictures available, hope you got it per mail ???

@leduyquang753
Copy link
Author

Okay...no pictures available, hope you got it per mail ???

Your reenactment doesn't help much unfortunately. The issue you showed is with your Python modules and I have suggested ways to fix that issue.

@StevenRott
Copy link

Hi,
I have now re-instaled all packages an started the CMD in Admin-Mode......the receiver.py is now loading, the PPTM ist blinking, but it breaks after a certain time with:

C:\Users\Steven\node_modules>python receiver.py
Traceback (most recent call last):
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Vorgang nicht verfügbar.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Steven\node_modules\receiver.py", line 22, in <module>
    app = Dispatch('PowerPoint.Application')
  File "C:\Program Files\Python\lib\site-packages\win32com\client\__init__.py", line 117, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(
pywintypes.com_error: (-2146959355, 'Starten des Servers fehlgeschlagen', None, None)

What ist wrong ? I'm using PowerPoint 2019 Professional......

@leduyquang753
Copy link
Author

Hi, I have now re-instaled all packages an started the CMD in Admin-Mode......the receiver.py is now loading, the PPTM ist blinking, but it breaks after a certain time with:

C:\Users\Steven\node_modules>python receiver.py
Traceback (most recent call last):
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 86, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Vorgang nicht verfügbar.', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Steven\node_modules\receiver.py", line 22, in <module>
    app = Dispatch('PowerPoint.Application')
  File "C:\Program Files\Python\lib\site-packages\win32com\client\__init__.py", line 117, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch, userName, clsctx)
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 106, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\Program Files\Python\lib\site-packages\win32com\client\dynamic.py", line 88, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(
pywintypes.com_error: (-2146959355, 'Starten des Servers fehlgeschlagen', None, None)

What ist wrong ? I'm using PowerPoint 2019 Professional......

According to this StackOverflow question, you need to run the Python script in a non-admin shell.

@StevenRott
Copy link

Can you help me please.....

@StevenRott
Copy link

In a none-admin shell, it comes:


C:\Users\Steven\node_modules>python receiver.py
C:\Users\Steven\node_modules\receiver.py:37: DeprecationWarning: There is no current event loop
  asyncio.get_event_loop().run_until_complete(mainFunction())
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 660, in __await_impl__
    await protocol.handshake(
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 325, in handshake
    raise RedirectHandshake(response_headers["Location"])
websockets.exceptions.RedirectHandshake: redirect to http://192.168.1.50:2909/dashboard/

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Steven\node_modules\receiver.py", line 37, in <module>
    asyncio.get_event_loop().run_until_complete(mainFunction())
  File "C:\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\Steven\node_modules\receiver.py", line 29, in mainFunction
    async with websockets.connect(serverAddress) as ws:
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 632, in __aenter__
    return await self
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 649, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "C:\Python310\lib\asyncio\tasks.py", line 447, in wait_for
    return fut.result()
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 675, in __await_impl__
    self.handle_redirect(exc.uri)
  File "C:\Python310\lib\site-packages\websockets\legacy\client.py", line 554, in handle_redirect
    new_wsuri = parse_uri(new_uri)
  File "C:\Python310\lib\site-packages\websockets\uri.py", line 77, in parse_uri
    raise exceptions.InvalidURI(uri, "scheme isn't ws or wss")
websockets.exceptions.InvalidURI: http://192.168.1.50:2909/dashboard/ isn't a valid URI: scheme isn't ws or wss

????

@StevenRott
Copy link

I updated asyncio:

C:\Users\Steven\node_modules>pip install --upgrade asyncio
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
Requirement already satisfied: asyncio in c:\python310\lib\site-packages (3.4.3)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (c:\python310\lib\site-packages)

C:\Users\Steven\node_modules>

is something wrong ??

@StevenRott
Copy link

With --user ther's no mistake:

C:\Users\Steven\node_modules>pip install --upgrade asyncio
Requirement already satisfied: asyncio in c:\python310\lib\site-packages (3.4.3)

C:\Users\Steven\node_modules>pip install --upgrade --user asyncio
Requirement already satisfied: asyncio in c:\python310\lib\site-packages (3.4.3)

C:\Users\Steven\node_modules>pip install --upgrade --user websockets
Collecting websockets
  Using cached websockets-10.0.tar.gz (81 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for websockets, since package 'wheel' is not installed.
Installing collected packages: websockets
    Running setup.py install for websockets ... done
Successfully installed websockets-10.0

C:\Users\Steven\node_modules>pip install --upgrade --user pywin32
Requirement already satisfied: pywin32 in c:\python310\lib\site-packages (302)

I'm really , really sad....

@StevenRott
Copy link

So do u have time for a short Teamviewer or something like that....?!?! :-)))))

@StevenRott
Copy link

With another WebServer (not XAMPP), especially APache24 I get this mistake:

C:\Users\Steven\node_modules>python receiver.py
C:\Users\Steven\node_modules\receiver.py:40: DeprecationWarning: There is no current event loop
  asyncio.get_event_loop().run_until_complete(mainFunction())
Traceback (most recent call last):
  File "C:\Users\Steven\node_modules\receiver.py", line 40, in <module>
    asyncio.get_event_loop().run_until_complete(mainFunction())
  File "C:\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\Steven\node_modules\receiver.py", line 32, in mainFunction
    async with websockets.connect(serverAddress) as ws:
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 632, in __aenter__
    return await self
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 649, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "C:\Python310\lib\asyncio\tasks.py", line 447, in wait_for
    return fut.result()
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 660, in __await_impl__
    await protocol.handshake(
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 327, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 200

Oh my god.....

@leduyquang753
Copy link
Author

With another WebServer (not XAMPP), especially APache24 I get this mistake:

C:\Users\Steven\node_modules>python receiver.py
C:\Users\Steven\node_modules\receiver.py:40: DeprecationWarning: There is no current event loop
  asyncio.get_event_loop().run_until_complete(mainFunction())
Traceback (most recent call last):
  File "C:\Users\Steven\node_modules\receiver.py", line 40, in <module>
    asyncio.get_event_loop().run_until_complete(mainFunction())
  File "C:\Python310\lib\asyncio\base_events.py", line 641, in run_until_complete
    return future.result()
  File "C:\Users\Steven\node_modules\receiver.py", line 32, in mainFunction
    async with websockets.connect(serverAddress) as ws:
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 632, in __aenter__
    return await self
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 649, in __await_impl_timeout__
    return await asyncio.wait_for(self.__await_impl__(), self.open_timeout)
  File "C:\Python310\lib\asyncio\tasks.py", line 447, in wait_for
    return fut.result()
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 660, in __await_impl__
    await protocol.handshake(
  File "C:\Users\Steven\AppData\Roaming\Python\Python310\site-packages\websockets\legacy\client.py", line 327, in handshake
    raise InvalidStatusCode(status_code, response_headers)
websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 200

Oh my god.....

It looks like that has something to do with your web server.

Please try to research for a while and take steps to solve your current problem first before posting rather than narrating everything you do here though as the latter creates unnecessary noise that I have to filter (and it spams my mailbox).

@StevenRott
Copy link

Sorry, I research a lot but don't find my problem......okay...it won't work....sorry for my unnecessary noise.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment