wanjohiryan / Arc3dia

Self-Hosted Stadia: Play with your friends online from any device and at any time
https://nestri.io
GNU Affero General Public License v3.0
844 stars 14 forks source link

[BUG] Cannot connect to a running Qwantify container #13

Closed WORMSTweaker closed 1 year ago

WORMSTweaker commented 1 year ago

Describe the bug After running the container with a game executable, the web interface is reachable, but trying to log in (both as an admin or a guest) fails, and the WebRTC connection is lost/not established.

To Reproduce Steps to reproduce the behavior:

  1. Deploy the container and verify that it is running successfully
  2. Open any browser, and reach the container login page
  3. Log in as either admin or a guest
  4. On Firefox: A "peer reset" error message appears On Chrome/Chromium: A "Reconnecting..." message appears

Expected behavior Accessing the streaming interface

Screenshots No screenshot, but a log output from the container, taken as soon as I try to log in:

documents-qwantify-1  | 2022-12-16 09:48:47,924 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF creating pipeline codec=opus module=capture src="pulsesrc device=auto_null.monitor ! audio/x-raw,channels=2 ! audioconvert ! opusenc inband-fec=true bitrate=128000 ! appsink name=appsink" submodule=stream-sink video_id=audio
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,926 DEBG 'pulseaudio' stdout output:
documents-qwantify-1  | I: [pulseaudio] client.c: Created 5 "Native client (UNIX socket client)"
documents-qwantify-1  | I: [pulseaudio] protocol-native.c: Client authenticated anonymously.
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,927 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF first listener, starting module=capture submodule=stream-sink video_id=audio
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,927 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF creating pipeline codec=vp8 module=capture src="ximagesrc display-name=:99.0 show-pointer=true use-damage=false ! video/x-raw,framerate=25/1 ! videoconvert ! queue !  vp8enc target-bitrate=1996800 cpu-used=4 end-usage=cbr threads=4 deadline=1 undershoot=95 buffer-size=12288 buffer-initial-size=6144 buffer-optimal-size=9216 keyframe-max-dist=25 min-quantizer=4 max-quantizer=20  ! appsink name=appsink" submodule=stream-sink video_id=video
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,929 DEBG 'pulseaudio' stdout output:
documents-qwantify-1  | I: [pulseaudio] source-output.c: Created output 5 "Record Stream" on auto_null.monitor with sample spec s16le 2ch 48000Hz and channel map front-left,front-right
documents-qwantify-1  | I: [pulseaudio] source-output.c:     media.name = "Record Stream"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.name = "neko"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     native-protocol.peer = "UNIX socket client"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     native-protocol.version = "33"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.process.id = "14"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.process.user = "neko"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.process.host = "38f9ce1af93d"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.process.binary = "neko"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.language = "C"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     window.x11.display = ":99.0"
documents-qwantify-1  | I: [pulseaudio] source-output.c:     application.process.machine_id = "6e189930411b75ca68345262639ad4f9"
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,929 DEBG 'pulseaudio' stdout output:
documents-qwantify-1  | I: [pulseaudio] protocol-native.c: Final latency 20.00 ms = 10.00 ms + 10.00 ms
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,936 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF first listener, starting module=capture submodule=stream-sink video_id=video
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,938 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF signaling state changed to have-local-offer module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:47,938 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF sent all ICECandidates module=webrtc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:51,954 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF signal update - RemoteAnswer id=ly2I3-QgLqopqLPM23W3WECi2ab7Kibx module=session
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:51,954 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF signaling state changed to stable module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:48AM INF Setting new connection state: Checking module=webrtc submodule=pion subsystem=ice
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:48:51,954 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:48AM INF ICE connection state changed: checking module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:48AM INF connection state has changed connection_state=checking module=webrtc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,004 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF Setting new connection state: Failed module=webrtc submodule=pion subsystem=ice
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,004 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF ICE connection state changed: failed module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM INF connection state has changed connection_state=failed module=webrtc
documents-qwantify-1  | 9:49AM INF peer connection state changed: failed module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM WRN peer failed id=ly2I3-QgLqopqLPM23W3WECi2ab7Kibx module=webrtc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,005 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF Setting new connection state: Closed module=webrtc submodule=pion subsystem=ice
documents-qwantify-1  | 9:49AM INF peer connection state changed: closed module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,005 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF ICE connection state changed: closed module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM WRN Failed to start manager: connecting canceled by caller module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM INF connection state has changed connection_state=closed module=webrtc
documents-qwantify-1  | 9:49AM WRN Failed to start SCTP: DTLS not established module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM INF peer closed id=ly2I3-QgLqopqLPM23W3WECi2ab7Kibx module=webrtc
documents-qwantify-1  | 9:49AM WRN undeclaredMediaProcessor failed to open SrtcpSession: the DTLS transport has not started yet module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 9:49AM WRN undeclaredMediaProcessor failed to open SrtpSession: the DTLS transport has not started yet module=webrtc submodule=pion subsystem=pc
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,020 DEBG 'pulseaudio' stdout output:
documents-qwantify-1  | I: [pulseaudio] source-output.c: Freeing output 5 "Record Stream"
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,020 DEBG 'pulseaudio' stdout output:
documents-qwantify-1  | I: [pulseaudio] client.c: Freed 5 "neko"
documents-qwantify-1  | I: [pulseaudio] protocol-native.c: Connection died.
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,021 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF destroying pipeline module=capture submodule=stream-sink video_id=audio
documents-qwantify-1  | 9:49AM INF last listener, stopping module=capture submodule=stream-sink video_id=audio
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,044 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF destroying pipeline module=capture submodule=stream-sink video_id=video
documents-qwantify-1  | 9:49AM INF last listener, stopping module=capture submodule=stream-sink video_id=video
documents-qwantify-1  | 
documents-qwantify-1  | 2022-12-16 09:49:04,044 DEBG 'neko' stdout output:
documents-qwantify-1  | 9:49AM INF destroying session module=session session_id=ly2I3-QgLqopqLPM23W3WECi2ab7Kibx
documents-qwantify-1  | 

Desktop (please complete the following information):

Additional context No additional context.

wanjohiryan commented 1 year ago

Hi @WORMSTweaker,

from what I see here:

9:49AM INF ICE connection state changed: failed module=webrtc submodule=pion subsystem=pc documents-qwantify-1 | 9:49AM INF connection state has changed connection_state=failed module=webrtc

Seems the ICE Connection can't go through.

Are you behind a firewall or are you using qwantify on a remote instance?

Try opening udp ports 52000-52100 and tell me if this helps.

WORMSTweaker commented 1 year ago

Hello @wanjohiryan,

No this is a local instance, running from a local docker daemon. Just to be sure, since this instance here is running on Windows, I tried disabling the default firewall, with no success.

For further testing, I will try the same scenario on a Linux machine, to know if this is a Windows only issue, or a wider issue with the container.

UPDATE: Testing the n.eko container lead to the same error, so this is an issue with the base image instead.

WORMSTweaker commented 1 year ago

Searching in the n.eko issues, I figured out what was the issue:

For a local instance of n.eko, the NEKO_NAT1TO1 env variable is needed, where the value of this env variable need to be your current local IP.

For example, adding - NEKO_NAT1TO1=10.13.12.34 to my compose fixed the issue.

Adding this option in the default compose, as a commented optional argument could be interesting, in case this issue is raised again.

This is the reference that explained why local containers aren't working

wanjohiryan commented 1 year ago

Oh, tbh i have not used NAT1TO1 yet. Thanks for the info.

I assume you can login to qwantify/n.eko now, right?

Is your game running?

WORMSTweaker commented 1 year ago

Yes, login in work

Although, my game wasn't running, might just be an issue with it tho since it was crashing, I'll try with a different game later An interesting thought for later would be to switch from base Wine to Proton-GE or similar for better game compatibility

wanjohiryan commented 1 year ago

Although, my game wasn't running

Might be the DX11 issue #2

An interesting thought for later would be to switch from base Wine to Proton-GE or similar for better game compatibility

Yeah, i will look into that. Though i have realised that anything 'custom' seems to be made for some app:

  1. Proton & Proton-Ge --> Steam
  2. Wine-GE --> Lutris

Adding this would add size to the docker image, so falling back to vanilla DXVK and VK3D is the only option

I might add a custom wine prefix for anyone wanting to play around with this.

WORMSTweaker commented 1 year ago

Might be the DX11 issue https://github.com/wanjohiryan/qwantify/issues/2

Actually no, I had trouble with this game on my host too, needing odd libraries, it's not too bothersome

Adding this would add size to the docker image, so falling back to vanilla DXVK and VK3D is the only option

If the image size is a concern, you can always allow through a volume to specify an external Wine runtime (that can be Wine-GE, or Proton), this way by default the image will not get bigger unless the user wants to. Something like - path\to\proton : \runtime in the volume, and adding a env variable like RUNTIME=<whatever the name of the runtime folder is>. This could be an alternative solution that wouldn't add size to the image.

wanjohiryan commented 1 year ago

Actually no, I had trouble with this game on my host too, needing odd libraries, it's not too bothersome

What game is it? if I may ask

If the image size is a concern, you can always allow through a volume to specify an external Wine runtime (that can be Wine-GE, or Proton), this way by default the image will not get bigger unless the user wants to.

Good idea, i had not considered this. But this would need the gamer to have some knowledge about wine, no?

Hmmm,if there was a volume mount for Wine runtime, then on container startup, the Go serverwould install any libaries the game needs and on finish finally run the game.

The wine prefix can be reused (this would save game progress between containers too)

WORMSTweaker commented 1 year ago

What game is it? if I may ask

Momodora 1, small indie game, it clearly does not support DXVK at all

But this would need the gamer to have some knowledge about wine, no?

Depends what you mean by Gamer, because if it is someone setting up a Qwantify instance, they already have a bit of knowledge about docker and volumes to set it up successfully, player connecting to this instance don't need to know about it.

Hmmm,if there was a volume mount for Wine runtime, then on container startup, the Go serverwould install any libaries the game needs and on finish finally run the game.

Since you already are installing winetricks, you could add a list of winetricks modules to install at runtime, in another variable (with this many variables, maybe a .env file would be needed?), which would let you customize the instance for a specific game

The wine prefix can be reused (this would save game progress between containers too)

It could be either copied at the end of the container life, and reimported when it starts again, that would work yes

WORMSTweaker commented 1 year ago

Just as a confirmation, I was able to play the tutorial level of The Escapists 2 without any flaws, I guess this can be marked as resolved Screenshot_20221216_205953

wanjohiryan commented 1 year ago

Depends what you mean by Gamer, because if it is someone setting up a Qwantify instance, they already have a bit of knowledge about docker and volumes to set it up successfully, player connecting to this instance don't need to know about it.

Yeah, this does make sense.

Since you already are installing winetricks, you could add a list of winetricks modules to install at runtime, in another variable (with this many variables, maybe a .env file would be needed?), which would let you customize the instance for a specific game

Yeah, or a .yaml config file. And probably a json file to keep track of all the modules already installed in a particular prefix. Might reduce time when playing a game with a preconfigured prefix.

It could be either copied at the end of the container life, and reimported when it starts again, that would work yes

Great ideas, my friend. This are really good ideas.

wanjohiryan commented 1 year ago

Just as a confirmation, I was able to play the tutorial level of The Escapists 2 without any flaws, I guess this can be marked as resolved

Nice one. So DX11 does work, hmm.

Was there any latency? I understand you're playing on the local machine, but was there any lags or hicups?

How was your gameplay?

WORMSTweaker commented 1 year ago

On a local machine, there was almost no input lag I tried with another game (Enter the Gungeon) where I tried to let one of my friends play They said there was some latency, less than a second (although this was at 1920x1080@60, which is sort of a lot), but it was playable

wanjohiryan commented 1 year ago

there was almost no input lag They said there was some latency, less than a second

That's good news. For a second I thought it would be disappointing for you :)

Thanks for the info.