나는 돛 0.10.5를 사용하고 앵글 - 돛을 가진 각진 프론트 엔드에있다.앵귤러 - 돛 websocket url undefined (ws : //www.undefined)
그것은 서버 측에서 다음과 같은 오류를 제공는 때마다 내 프런트 엔드 측 컨트롤러 코드에서 $ sails.get
에 의해 API 호출 :
io.sails.url = 'http://localhost:1337'; io.socket.get('http://localhost:1337/admin/v1/user/subscribe', function (body, response) { console.log('Sails responded with: ', body); console.log('with headers: ', response.headers); console.log('and with status code: ', response.statusCode); });
및 콘솔
Sails responded with: Object {} app.js:167 with headers: Object {} app.js:168 and with status code: 200
입니다 하지만 백엔드 사이드 돛 콘솔에서 이런 오류가 발생합니다
debug: -------------------------------------------------------- debug: :: Fri Dec 19 2014 10:44:25 GMT+0530 (India Standard Time) debug: Environment : development debug: Port : 1337 debug: -------------------------------------------------------- error: Error: res.redirect() :: [socket.io] :: Cannot redirect socket to invalid location :: 'ws://www.undefinedhttp://localhost:1337/admin/v1/user/subscribe' at Object.Err.invalidRedirect (C:\wamp\www\i-phone\i-phone\node_modules\sails\lib\hooks\sockets\lib\interpreter\interpret.js:33:14) at ResStream.doRedirect (C:\wamp\www\i-phone\i-phone\node_modules\sails\lib\hooks\sockets\lib\interpreter\interpret.js:310:31) at C:\wamp\www\i-phone\i-phone\node_modules\sails\lib\hooks\sockets\lib\interpreter\saveSessionAndThen.js:23:7 at C:\wamp\www\i-phone\i-phone\node_modules\sails\lib\hooks\session\index.js:59:17
내 경로 파일은 다음과 같다 :
'get /admin/v1/user/subscribe': 'UserController.subscribe',
과의 UserController.js :
subscribe: function (req, res) { console.log('aaaaaaaaaaaaaaaaaaaa') User.find().exec(function(err,users){ // subscribing this socket to User model classroom User.subscribe(req.socket); // subscribing this socket to User model instance room User.subscribe(req.socket,users); console.log('subscribe') }) }
에 의해 해결된다
www.undefined로 리디렉션도되고 있습니다 먹으 렴 제안했지만, 여전히 작동하지 않습니다, 나는 당신이 볼 수있는 지금 내 질문을 업데이 트했습니다 ... –