2017-10-08 5 views
0

私はブラウザクライアント(webpackを使用)から正常に接続できるfeathersjsサーバーを実行しています。今、私は同じサーバーに接続しようとしていますnodejsアプリラズベリーPi3で実行されます。私は見つけるときにサーバーの活動を参照してください。私はそのサービスで作成するフック・ロガーをセットアップし、何も記録しません。私は、クライアントが決して接続していないと仮定することができます。私はちょうどdevで認証モジュールが必要ないので、そのサービスには認証フックはありません。Feathersjsノードソケットクライアントが接続されていません

私はRPIからサーバーにpingを実行できますが、RPIのブラウザにサーバーのIP /ポートを置くと、私は "羽毛サーバーがクライアントを使用しています"というページが表示されます。サーバーは正常です。

何が起こっているのかを追跡する方法についてのヘルプ。 (クライアント上の)接続ログがなければ、何が起こっているのかを知ることはできません。私が得るのは、.catchからのタイムアウトエラーです。

以下は私のクライアントコードです。これは、動作中のブラウザクライアントのクライアントコードです。

作業ブラウザクライアントセットアップ

import feathers from 'feathers' 
import hooks from 'feathers-hooks' 
import socketio from 'feathers-socketio' 
import auth from 'feathers-authentication-client' 
import io from 'socket.io-client' 

// const socket = io('http://localhost:3030', {transports: ['websocket']}) 
// const socket = io('http://192.168.43.114:3030', {transports: ['websocket']}) 
const socket = io('http://192.168.0.51:3030', { transports: ['websocket'] }) 

const api = feathers() 
    .configure(hooks()) 
    .configure(socketio(socket)) 

// .configure(AUTH({ストレージ:window.localStorage}))クライアントのセットアップnodejs動作しない

export default api 

const feathers = require('feathers/client'); 
const socketio = require('feathers-socketio/client'); 
const hooks = require('feathers-hooks'); 
// const errors = require('feathers-errors'); // An object with all of the custom error types. 
// const auth = require('feathers-authentication-client'); 

const io = require('socket.io-client/dist/socket.io'); 

const socket = io('http://192.168.0.51:3030', { transports: ['websocket'] }) 

const feathersClient = feathers() 
    .configure(hooks()) 
    .configure(socketio(socket)) 
//.configure(auth()) 

module.exports = feathersClient; 

私のサービスでfindをやっているノードアプリ。 .catchから

const api = require('./api') 

const switches = api.service('switches') 

switches.find({ 
    paginate: false 
}) 
    .then((response) => { 
     console.log('loading all switch data', response.data) 
    }) 
    .catch((err) => { 
     console.log('error loading switch data', err) 
    }) 

エラー

error loading switch data Error: Timeout of 5000ms exceeded calling switches::find 
    at Timeout._onTimeout (/opt/lighting-dev/node_modules/feathers-socket-commons/lib/client.js:87:25) 
    at ontimeout (timers.js:469:11) 
    at tryOnTimeout (timers.js:304:5) 
    at Timer.listOnTimeout (timers.js:264:5) 

答えて

0

NPM /ノードクライアントの羽のドキュメントが間違ってい判明。 https://docs.feathersjs.com/api/client.html

const io = require('socket.io-client/dist/socket.io'); 

を必要とブラウザのみ

nodejsためには

const io = require('socket.io-client); 

ちょうどベースのクライアントを使用して、それが動作するためです。

関連する問題