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

Connection Refused to WebSocket Server #2

Open
Fierce-Cat opened this issue Mar 3, 2019 · 4 comments
Open

Connection Refused to WebSocket Server #2

Fierce-Cat opened this issue Mar 3, 2019 · 4 comments

Comments

@Fierce-Cat
Copy link

I installed the background as described in the readme, but the player returned the following:
Connection with 'ws://127.0.0.1:1207 /' WebSocket failed: connection establishment error: net :: ERR_CONNECTION_REFUSED

The following code has an error:
20190302180919

I am sure that server.js is running on the server before accessing the player (according to readme):
20190302181044
The "danmuku" folder belongs to root:root and the permissions are 755.

If you wish to view my test page, this is the link: live.kerbcat.com

Hope to get help as soon as possible, thank you.

@Izumi-kun
Copy link
Owner

Change 127.0.0.1 to external host name.

@Fierce-Cat
Copy link
Author

After I replaced 127.0.0.1 with the external address of my server, it didn't display an error, but at the same time I opened two browser windows and danmu still didn't show up.

@Fierce-Cat
Copy link
Author

Trying to rebuild a server and reinstall it, it is still unusable. Is it due to the update of Dplayer version?

@SukiYume
Copy link

I don't know if you still care about this problem, but I solved it. There are a few things that need to be modified.

First, the server.js

var hexColorRegExp = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
var typeRegExp =/^(top|bottom|right)$/;
//// change these two variables to the following form, because the message format of dplayer has changed.  ////
var hexColorRegExp = /^\d{8}$/
var typeRegExp = /^(0|1|2)$/;

If you use your domain by nginx, and applied https, should add websocket proxy to nginx.conf. For example:

map $http_upgrade $connection_upgrade {
            default upgrade;
            '' close;
}
server
{
  		...
      server_name your.domain;
      root  /path/to/index.html;
         
      location / {
          index  index.html index.htm;
      }

      location /websocket {
          proxy_pass http://127.0.0.1:port;
       	  proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection $connection_upgrade;
          proxy_set_header HOST $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header X-Forwarded-Proto $scheme;
          proxy_pass_request_headers on;
      }
  		...
}

Then, change your index.html

apiBackend: createApiBackend('ws://localhost:1207', function (dan) {
<!-- change the url to the following form, if https, ws->wss, if not, keep ws. -->
apiBackend: createApiBackend('wss://your.domain/websocket', function (dan) {

Hope this can help you.

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