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

ERROR: Cocos Creator 3.8.2 and colyseus.js 0.15 #141

Open
human211 opened this issue Mar 4, 2024 · 1 comment
Open

ERROR: Cocos Creator 3.8.2 and colyseus.js 0.15 #141

human211 opened this issue Mar 4, 2024 · 1 comment

Comments

@human211
Copy link

human211 commented Mar 4, 2024

when I launch it in the browser everything is ok. but if I run it in the simulator, it’s an error. Therefore, the connection to the server is not created and the game does not start.

import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;
import Colyseus from 'db://colyseus-sdk/colyseus.js';

ccclass('test')
export class test extends Component {
    start () {
        this.client = new Colyseus.Client('ws://localhost:2567');
    }
}

LOG:

10:44:49 [ERROR]: JS: TypeError: Cannot read properties of undefined (reading 'toLowerCase')
TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at new <anonymous> (jsb-adapter/web-adapter.js:350:35)
    at new Client (http://192.168.1.100:7456/scripting/x/chunks/06/06cb93b53c4faf511f8419cd7b43f5ca107a4e76.js:6151:27)
    at test.start (http://192.168.1.100:7456/scripting/x/chunks/3f/3fed73c55abf94efb7af37eb78a375e40c473aca.js:63:25)
    at eval (eval at createInvokeImplJit (src/cocos-js/builtin-res-mgr.jsb-782de3de.js:8047:69), <anonymous>:3:65)
    at OneOffInvoker._invoke (src/cocos-js/builtin-res-mgr.jsb-782de3de.js:8054:19)
    at OneOffInvoker.invoke (src/cocos-js/builtin-res-mgr.jsb-782de3de.js:7998:22)
    at ComponentScheduler.startPhase (src/cocos-js/builtin-res-mgr.jsb-782de3de.js:8161:35)
    at Director.tick (src/cocos-js/director-cf2afd11.js:1477:41)
    at Game._updateCallback (src/cocos-js/deprecated-88c49970.js:1080:28)
    at src/cocos-js/deprecated-88c49970.js:140:26
@endel
Copy link
Member

endel commented Jun 7, 2024

I consider this to be a bug on Cocos Creator: cocos/cocos-engine#13546 (comment).
If URL is available in a native environment, it should implement its basic functionality.

As a workaround, you can provide the endpoint as an object for Colyseus.Client:

const client = new Colyseus.Client({ hostname: "localhost", port: 2567, secure: false  });

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

2 participants