我正在使用反应js并使用套接字并表达设置多人游戏
我收到此错误:
轮询xhr.js:264 获取https://localhost:3000/socket.io/?EIO=3&transport=polling&t=LqjOuC2 net :: ERR_CONNECTION_CLOSED
我已经5次谷歌这个错误,并用app,socket,express和http调整了我的导入,
Server.js
var app = require('express')();
var http = require('http').Server(app);
const port = process.env.PORT || 3001;
http.listen(port, ()=> {console.log("+++Express Server with Socket
Running!!!")})
var io = require('socket.io').listen(http);
....
....
前端
import React, { Component } from 'react';
import Test from "./Test"
import io from "socket.io-client"
import {BrowserRouter as Router, Route, Link} from 'react-router-dom'
// ***********************************
// Handles user creation and contains routes to game
// ***********************************
class App extends Component {
constructor(props){
super(props)
this.home = this.home.bind(this)
this.socket = io.connect("https://localhost:3000")
}
....
....
我的package.json设置了代理:" https://localhost:3000/"
任何人都知道如何修复连接错误,非常感谢任何帮助!