Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to WebRTC on the browser after running the code. #3

Open
JimBeam2019 opened this issue Feb 22, 2022 · 9 comments
Open

Comments

@JimBeam2019
Copy link

Hi Will, thank you for sharing the WebRTC Game example code. I was intrigued by what WebRTC can do on gaming after watching your YouTube video, so I've tried out the code. But I've failed to generate the same result as yours in the video, and I hope you could give me a hint on what I may have gone wrong along with the steps.

So, after cloning the project to my PC(Debian Linux), I added the localhost IP (127.0.0.1) to the main.go file as the instruction says and ran the command line go run . in the terminal (go version: go 1.17.6). The result showed as below.

Listening for WebRTC traffic at [::]:80

Then, when I opened a browser (Chrome) with http://localhost, what I was given was a web page with a message input area and a Send button like the pic. There was no game action area and the terminal didn't have any further updates from the terminal either. I'm not sure what had gone wrong, so could you give me any advice, please? Thanks.

Screenshot_2022-02-22_11-24-03

@wawesomeNOGUI
Copy link
Owner

Hi! You also need to add the address of your server to:

ws = new WebSocket("ws://127.0.0.1:80/echo"); //address to connect to, /echo triggers go echo function

@AlinaDovbysheva
Copy link

AlinaDovbysheva commented Jun 18, 2022

Hi. Same problem. I'm trying to add 127.0.0.1:80 and my local 192.168.1.3 from ipconfig
What another address if runing local?
Thanks.
Chrome:
image

@wawesomeNOGUI
Copy link
Owner

@AlinaDovbysheva Hi! I did find a typo that shouldn't affect anything, but I went ahead and updated index.html, so definitely try that. Let me know if it works.

@AlinaDovbysheva
Copy link

image
Maybe some misstakes on my side.
Is it correct:

  1. index.html ws = new WebSocket("ws://127.0.0.1:80/echo")
  2. main.go
    udpListener, err := net.ListenUDP("udp", &net.UDPAddr{
    IP: net.IP{0, 0, 0, 0},
    Port: 80,
    })
    .....
    settingEngine.SetNAT1To1IPs([]string{}, webrtc.ICECandidateTypeHost)
    ......
    err = http.ListenAndServe(":80", nil) //Http server blocks
    ?

@wawesomeNOGUI
Copy link
Owner

wawesomeNOGUI commented Jun 18, 2022

Hmmm, that all looks fine. Is the go program showing that more ICE candidates are being sent? It will look like this in the terminal: {candidate:4212933298 1 udp ... }

@AlinaDovbysheva
Copy link

image
In index.html pc.iceConnectionState does not go to the connected state

@AlinaDovbysheva
Copy link

problem with chrome
I launched in Edge and its working
Now I'm trying to figure out why it doesn't work in chrome

@wawesomeNOGUI
Copy link
Owner

Ohh interesting, yeah it is always tricky to work out bugs between different browsers :D It works for me in chrome version 102.0.5005.115, are you running the same version of chrome?

@AlinaDovbysheva
Copy link

The same 102.0.5005.115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants