2016-05-22 3 views
0

に行くためにネイティブwebviewに反応するときにnet :: ERR_CONNECTION_REFUSEDを取得するこれは愚かな質問ですが申し訳ありませんが、私はこれを初めて理解しています。localhost:9000/login

私は自分のノードサーバーをlocalhost:9000上で実行しています。私はwebviewを動作させようとしています。ここで私は返すようにしようとしているものだ - 私は次のエラーを取得するため

 <View style={[styles.container]}> 
     <WebView 
      ref={'webview'} 
      automaticallyAdjustContentInsets={false} 
      style={styles.webView} 
      source={{uri: 'http://localhost:9000/login'}} 
      javaScriptEnabled={true} 
      onNavigationStateChange={this.onNavigationStateChange.bind(this)} 
      startInLoadingState={true} 
      scalesPageToFit={true} 
     /> 
     </View> 

はしかし、これは動作しません:私はhttp://google.comとしてソースURIを置くとき

Encountered an error loading page Object {canGoForward: false, code: -6, canGoBack: false, description: "net::ERR_CONNECTION_REFUSED", loading: false…}canGoBack: falsecanGoForward: falsecode: -6description: "net::ERR_CONNECTION_REFUSED"loading: falsetarget: 9title: ""url: "http://localhost:9000/login"__proto__: ObjectreactConsoleError @ ExceptionsManager.js:76console.error @ YellowBox.js:48onLoadingError @ WebView.android.js:300proxiedMethod @ createPrototypeProxy.js:44invokeGuardedCallback @ ReactErrorUtils.js:26executeDispatch @ EventPluginUtils.js:87executeDispatchesInOrder @ EventPluginUtils.js:110executeDispatchesAndRelease @ EventPluginHub.js:42executeDispatchesAndReleaseTopLevel @ EventPluginHub.js:53forEachAccumulated @ forEachAccumulated.js:26processEventQueue @ EventPluginHub.js:215runEventQueueInBatch @ ReactEventEmitterMixin.js:18handleTopLevel @ ReactEventEmitterMixin.js:29(anonymous function) @ ReactNativeEventEmitter.js:122perform @ Transaction.js:136batchedUpdates @ ReactDefaultBatchingStrategy.js:63batchedUpdates @ ReactUpdates.js:97_receiveRootNodeIDEvent @ ReactNativeEventEmitter.js:121receiveEvent @ ReactNativeEventEmitter.js:135__callFunction @ MessageQueue.js:185(anonymous function) @ MessageQueue.js:89guard @ MessageQueue.js:43callFunctionReturnFlushedQueue @ MessageQueue.js:88onmessage @ debuggerWorker.js:39

WebViewが正常に動作しますか何か。助けてもらえますか?ありがとう

答えて

5

ローカルホストはAndroidデバイス自体になります。 AndroidエミュレータからホストOSにアクセスするには、10.0.2.2:9000または実際のIPアドレスを使用できます。

+0

ダニエルに感謝します。私は実際には私のコンピュータのlocal_IP:ポートを使ってそれを使う必要がありました。 :) – user3152131

+0

完璧なソリューション。それは二度との瞬間だった。 – zappullae

0

個人的に、私はちょうど好むadb reverse tcp:9000 tcp:9000