hl2ss icon indicating copy to clipboard operation
hl2ss copied to clipboard

ConnectionResetError: [Errno 104] Connection reset by peer #69

Open eleanorchen0 opened this issue 5 months ago • 2 comments

Whenever I try to run client_stream_pv.py I get this error, however I can stream other sensors like vlc. I saw another post with a similar issue, but Iit seemed like their's just started working, so it didn't help resolve the error. I'm using a virtual machine on a mac with Miniconda python version 3.10, and I have all the libraries downloaded as well. I checked the connectivity with the HoloLens using the IP Address, but I get this error when trying to run client_stream_pv.py

Traceback (most recent call last): File "/home/eleanor/Downloads/hl2ss-main/viewer/client_stream_pv.py", line 102, in data = client.get_next_packet() File "/home/eleanor/Downloads/hl2ss-main/viewer/hl2ss.py", line 1788, in get_next_packet data = super().get_next_packet(wait) File "/home/eleanor/Downloads/hl2ss-main/viewer/hl2ss.py", line 829, in get_next_packet data = self._client.get_next_packet(wait) File "/home/eleanor/Downloads/hl2ss-main/viewer/hl2ss.py", line 454, in get_next_packet self._unpacker.extend(self._client.recv(self._chunk_size)) File "/home/eleanor/Downloads/hl2ss-main/viewer/hl2ss.py", line 347, in recv chunk = self._socket.recv(chunk_size) ConnectionResetError: [Errno 104] Connection reset by peer

Any ideas of what could fix this issue? Thank you!

eleanorchen0 avatar Jul 21 '25 14:07 eleanorchen0

Hi, try this script:


from pynput import keyboard

import cv2
import hl2ss_imshow
import hl2ss
import hl2ss_lnm
import hl2ss_utilities

# Settings --------------------------------------------------------------------

# HoloLens address
host = "192.168.1.7"

# Camera parameters
width     = 1920
height    = 1080
framerate = 30

#------------------------------------------------------------------------------

operating_mode = hl2ss.StreamMode.MODE_1
video_profile = hl2ss.VideoProfile.H265_MAIN
divisor = 1
bitrate = hl2ss_lnm.get_video_codec_default_bitrate(width, height, framerate, divisor, video_profile)

listener = hl2ss_utilities.key_listener(keyboard.Key.esc)
listener.open()

codec = hl2ss.decode_pv(video_profile)

client = hl2ss._gatherer()
client.open(host, hl2ss.StreamPort.PERSONAL_VIDEO, hl2ss_lnm.create_sockopt(), hl2ss.ChunkSize.PERSONAL_VIDEO, operating_mode)
configuration = bytearray()
configuration.extend(hl2ss._create_configuration_for_mode(hl2ss._PVCNT.START | operating_mode))
configuration.extend(hl2ss._create_configuration_for_mrc_video(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
configuration.extend(hl2ss._create_configuration_for_video_format(width, height, framerate))
configuration.extend(hl2ss._create_configuration_for_video_divisor(divisor))
configuration.extend(hl2ss._create_configuration_for_video_encoding(video_profile, hl2ss.H26xLevel.DEFAULT, bitrate))
configuration.extend(hl2ss._create_configuration_for_h26x_encoding({hl2ss.H26xEncoderProperty.CODECAPI_AVEncMPVGOPSize : framerate}))
client.sendall(bytes(configuration))

while (not listener.pressed()):
    data = client.get_next_packet()    
    data.payload = codec.decode(data.payload, 'bgr24')
    cv2.imshow('Video', data.payload.image)
    cv2.waitKey(1)

client.close()

jdibenes avatar Jul 24 '25 21:07 jdibenes

I once encountered the same error. For my case the problem is using illegal settings for pv camera.(I was trying to use 5fps or so..) Using the configs from https://github.com/jdibenes/hl2ss/blob/main/etc/pv_configurations.txt solved my problem.

Youdnot avatar Aug 06 '25 03:08 Youdnot