Skip to content

ConnectionRefusedError: Unable to make OBS and obs-websocket-py cooperate #87

@austin-funk

Description

@austin-funk

Hi all, I'm currently working on a script that can dynamically save video segments to different folders based on the time of day. However, I'm getting stuck on the first step, and have very little networking experience to lean on. Any help would be greatly appreciated.
I've tried using OBS version 29.0.0 and am currently using version 27.1.3. I was using Python 3.7 but switched to 3.6.8 to be compatible with the older version of OBS. I've tried two versions of obs-websocket, 5.0.0 and 4.9.1. I've tried turning off all firewalls and both using a password and not using a password. I was able to see and change options for the websocket under Tools in OBS 29.0.0, but even with multiple reinstalls I can't make it work for 27.1.3.
Here is the error message from OBS when using OBS 27.1.3, Python 3.6.8, websocket 4.9.1, no firewalls, no authentication:

[####.py] Traceback (most recent call last):
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\obswebsocket\core.py", line 84, in connect
[####.py]     self.ws.connect(url)
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\websocket\_core.py", line 250, in connect
[####.py]     options.pop('socket', None))
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\websocket\_http.py", line 130, in connect
[####.py]     sock = _open_socket(addrinfo_list, options.sockopt, options.timeout)
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\websocket\_http.py", line 206, in _open_socket
[####.py]     raise err
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\websocket\_http.py", line 185, in _open_socket
[####.py]     sock.connect(address)
*[####.py] ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it*
[####.py]
[####.py] During handling of the above exception, another exception occurred:
[####.py] 
[####.py] Traceback (most recent call last):
[####.py]   File "C:/Users/####/Documents/OBScripts\####.py", line 18, in <module>
[####.py]     client.connect()
[####.py]   File "C:\Users\####\AppData\Local\Programs\Python\Python36\lib\site-packages\obswebsocket\core.py", line 108, in connect
[####.py]     raise exceptions.ConnectionFailure(str(e))
[####.py] obswebsocket.exceptions.ConnectionFailure: [WinError 10061] No connection could be made because the target machine actively refused it

Here is the code associated with this error message. I have commented out sections of it and found that the issue occurs when client.connect() is uncommented:

import time
import obspython as obs
import obswebsocket

def script_description():
    return """<center><h2>####</h2></center>
              <p>Continuously saves increments of videos and deletes
              old videos for storage reasons.</p>"""

base_path = "C:\\Users\\####\\Videos\\NewFolder"
seconds_passed = 0
socket_password = "RfdsH833NbKSDpl09DdieqwpmvnIJf121fJ8Njf8GFY8jdb3"

client = obswebsocket.obsws("localhost", 4455)
client.connect()
# client.call(obswebsocket.requests.SetRecordingFolder(base_path))
print(base_path)
client.disconnect()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions