DEMO treasures 客户端链接不上 #135

Closed
liketo opened this Issue Mar 18, 2013 · 22 comments
@liketo

运行无错误提示,输入名字后点start name按钮没反应。
function entry(name, callback) {
pomelo.init({host: config.GATE_HOST, port: config.GATE_PORT, log: true}, function() {
pomelo.request('gate.gateHandler.queryEntry', {uid: name}, function(data) {

跟踪看了下,init会执行,host跟port(3014)都是正确的,但回调函数“pomelo.request”不执行。

@numbcoder

看看服务端有什么错误么?

你改什么代码了么?

@demon0925
NetEase member

把init里面的参数和server.json中的gate服务器配置贴一下。
你是在本机访问还是在另外的机器上访问的?
init是建立连接,在连接成功之后会调用,之后没有回调说明没有连上服务器

@liketo

都是本地连接的,系统是win7
server.json
{
"development": {
"connector": [
{"id": "connector-server-1", "host": "127.0.0.1", "port": 3150, "clientPort": 3010, "frontend": true},
{"id": "connector-server-2", "host": "127.0.0.1", "port": 3151, "clientPort": 3011, "frontend": true}
],
"area": [
{"id": "area-server-1", "host": "127.0.0.1", "port": 3250, "areaId": 1}
],
"gate": [
{"id": "gate-server-1", "host": "127.0.0.1", "clientPort": 3014, "frontend": true}
]
},
"production": {
"connector": [
{"id": "connector-server-1", "host": "127.0.0.1", "port": 3150, "clientPort": 3010, "frontend": true},
{"id": "connector-server-2", "host": "127.0.0.1", "port": 3151, "clientPort": 3011, "frontend": true}
],
"area": [
{"id": "area-server-1", "host": "127.0.0.1", "port": 3250, "areaId": 1}
],
"gate": [
{"id": "gate-server-1", "host": "127.0.0.1", "clientPort": 3014,"frontend": true}
]
}
}
//////////////////////////////////////////////////////////////////////////////////////
master.json
{
"development":{
"id":"master-server-1",
"host":"127.0.0.1",
"port":3005,
"queryPort":3015,
"wsPort":2337
},

"production":{
    "id":"master-server-1",
    "host":"127.0.0.1",
    "port":3005,
    "queryPort":3015,
    "wsPort":2337
}

}

@ezhozhe

哥们,和你一样的问题,最后解决没?我如果绕过gate,直接连connector是可以连通的

@numbcoder

@ezhozhe 请问你是直接从 github 拉代码运行的么?
这个在我在是没问题的呀。

你在 gateHandler 里打印一下,看是不是出什么错了?

@sword721

我也是这个问题啊,有没有解决呢?

@numbcoder

@sword721 能给一些详细的错误信息么?

@sword721

function entry(name, callback) {
console.log(config.GATE_HOST);
console.log(config.GATE_PORT);
pomelo.init({host: config.GATE_HOST, port: config.GATE_PORT, log: true}, function() {
console.log("test init");
pomelo.request('gate.gateHandler.queryEntry', {uid: name}, function(data) {

      pomelo.disconnect();

      if (data.code === 2001) {
        alert('server error!');
        return;
      }
      if (data.host === '10.10.28.190') {
        data.host = location.hostname;
      }
      // console.log(data);
      pomelo.init({host: data.host, port: data.port, log: true}, function() {
        if (callback) {
          console.log("nimeia");
          callback();
        }
      });
    });
  });
}

点了登陆按钮没反应啊,
这里没执行了。
pomelo.request('gate.gateHandler.queryEntry', {uid: name}, function(data) {

@sword721

server.js

{
"development": {
"connector": [
{"id": "connector-server-1", "host": "10.10.28.190", "port": 3150, "clientPort": 3010, "frontend": true},
{"id": "connector-server-2", "host": "10.10.28.190", "port": 3151, "clientPort": 3011, "frontend": true}
],
"area": [
{"id": "area-server-1", "host": "10.10.28.190", "port": 3250, "areaId": 1}
],
"gate": [
{"id": "gate-server-1", "host": "10.10.28.190", "clientPort": 3014, "frontend": true}
]
},
"production": {
"connector": [
{"id": "connector-server-1", "host": "10.10.28.190", "port": 3150, "clientPort": 3010, "frontend": true},
{"id": "connector-server-2", "host": "10.10.28.190", "port": 3151, "clientPort": 3011, "frontend": true}
],
"area": [
{"id": "area-server-1", "host": "10.10.28.190", "port": 3250, "areaId": 1}
],
"gate": [
{"id": "gate-server-1", "host": "10.10.28.190", "clientPort": 3014}
]
}
}

@sword721

没有任何错误提示信息,是不是没链接上服务器。

@w2moon
@fantasyni
NetEase member

这个问题可以到 pomelo club 去讨论

@numbcoder

@sword721 你配置的 IP 是外网地址么?
貌似是ip的问题,如果是本机的话,直接 127.0.0.1

@sword721

127.0.0.1也不行,是内网的地址,我是在虚拟机里面运行的。

@xiecc
NetEase member

这个有点奇怪,解决了吗

@kejunxia

碰到同样的问题。
点了start game没反应。在客户端里设断点也是发现main.js里的pomelo.init的回调函数没有被执行,所以gate handler也没有执行。
如果在设step的断点进pomelo.init里一步步执行,如果一步一步的执行慢点,会出现随机的执行这个callback
var onclose = function(event){
pomelo.emit('close',event);
console.log('socket close: ', event);
};

控制台里的log

socket close:

CloseEvent {reason: "", code: 1006, wasClean: false, clipboardData: undefined, cancelBubble: false…}
bubbles: false
cancelBubble: false
cancelable: false
clipboardData: undefined
code: 1006
currentTarget: WebSocket
defaultPrevented: false
eventPhase: 0
reason: ""
returnValue: true
srcElement: WebSocket
target: WebSocket
timeStamp: 1365601312205
type: "close"
wasClean: false
proto: CloseEvent

如果执行快了就不会收到。以上是chrome测的

用firefox测,控制台显示

[23:52:56.537] Firefox can't establish a connection to the server at ws://localhost:3014/. @ http://localhost:3001/js/lib/build/build.js:1439
[23:52:56.538] socket error: [object Event]
[23:52:56.538] socket close: [object CloseEvent]

@it114

同问 ???也遇到了同样的问题~~~~~~~~~~~~~~~~解决了吗 ???

@changchang

pomelo是什么版本的?升级到0.3.7试试看

@xiecc
NetEase member

http://nodejs.netease.com 欢迎到那边灌水

@xiecc xiecc closed this May 7, 2013
@zhangchunsheng

就没有人解决这个问题,又不是一个人反应,我也是这个问题,浪费大家时间

@numbcoder

@zhangchunsheng 我们重现不了这个问题,都不知道是那出错了,怎么解决?

@youxiachai

.....我就很正常....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment