4
服務器代碼:socket.io客戶端無法獲得授權失敗的原因
//run with node-dev server.js
var remoteServer = io.of('/remote');
remoteServer.authorization(function(handshakeData, callback){
return callback('unknown clientType', false);
}
服務器日誌:
You can visit your app with http://localhost:3000
info - handshake authorized l4FzYiWpHo2d8VeoB3Zo
warn - handshake error unknown clientType for /remote
客戶端代碼:
//run with node-dev client.js
var io = require('socket.io/node_modules/socket.io-client');
var client = io.connect('http://localhost:3000/remote');
client.on('connect_failed', function(reason){
console.log('connect_failed:', reason);
});
//will call this because it's Namespace authorization
client.on('error', function(reason){
console.log('error:', reason);
});
客戶端日誌:
//error reason miss.
E:\Workspace\TZ\SmartDoor\client>node-dev client.js
error:
閱讀後src和測試,發現授權不允許自定義錯誤味精,只有回調(空,假的),然後客戶端有:「錯誤:未授權」 – atian25 2012-08-04 10:00:09
現在,我應該刪除這個問題還是近?哪個操作 – atian25 2012-08-04 10:01:53
那麼我怎麼能告訴客戶端授權更多細節失敗msg? – atian25 2012-08-04 10:05:58