2013-10-22 2 views
0

Twit module을 사용하여 AngularJS 앱에서 Twitter 스트림을 표시하고 있습니다. 사용자가 중지 버튼을 클릭 할 때 스트림을 끄는 옵션을 제공하려고합니다.Nodejs 스트림 중지시 Twit 모듈 오류가 발생했습니다.

스트리밍 처리하는 스크립트 : 다음과 같은 오류를 출력 콘솔을 중지 버튼을 누른 후

var Twit = require('twit'); 
var T = new Twit({ 
    consumer_key  : 'XXX', 
    consumer_secret  : 'XXX', 
    access_token  : 'XXX', 
    access_token_secret : 'XXX' 
}); 

function streamingHashtag(streamBool) 
{  
    var stream = T.stream('statuses/filter', { track: 'test' }); 

    stream.on('tweet', function (tweet) { 
    console.log(tweet); 
    }); 

    stream.on('disconnect',function(disconnectMessage){ 
    stream.stop(); 
    }); 

    if(streamBool == false){ 
    stream.stop(); 
    console.log('Stream stopped by user'); 
    } 
} 

및 스트림이 계속 :

message: "Cannot call method 'abort' of undefined", stack: "TypeError: Cannot call method 'abort' of undefined…es\connect\lib\middleware\methodOverride.js:37:5)"} 
message: "Cannot call method 'abort' of undefined" 
stack: "TypeError: Cannot call method 'abort' of undefined? at OARequest.stop ([localhost]\node_modules\twit\lib\oarequest.js:110:16)? at Object.streamingHashtag ([localhost]\server\library\twitter.js:40:10)? at exports.twitterStream ([localhost]\server\routes\index.js:11:10)? at callbacks ([localhost]\node_modules\express\lib\router\index.js:161:37)? at param ([localhost]\node_modules\express\lib\router\index.js:135:11)? at pass ([localhost]\node_modules\express\lib\router\index.js:142:5)? at Router._dispatch ([localhost]\node_modules\express\lib\router\index.js:170:5)? at Object.router ([localhost]\node_modules\express\lib\router\index.js:33:10)? at next ([localhost]\node_modules\express\node_modules\connect\lib\proto.js:190:15)? at Object.methodOverride [as handle] ([localhost]\node_modules\express\node_modules\connect\lib\middleware\methodOverride.js:37:5)" 

나는 최신 버전을 실행하고있어 (package.json은 "version": "1.1.11"이라고 말함) 조사한 결과 OARequest.js에서 abort()를 지시하는 stop 함수를 발견했습니다.

내가 뭘 잘못하고 있니?

답변

0

동일한 오류가 발생하여 나중에 참조 할 수있는 사람은 대답을 찾은 지금 내 자신의 질문에 대답 해주십시오. 오류는 변수를 선언했음을 확신하는 동안 정의되지 않은 메서드에 '중단'메서드가 없다고 명시했습니다.

이 오류는 함수를 두 번 호출하여 이전 변수를 사용할 수없는 새 범위를 만들 때 발생합니다. 함수 외부에서 변수를 정의하면 전역 적으로이를 수정했습니다.

관련 문제