How to know whether a service path is invalid or not by feathersjs client?

300 views Asked by At

Feathersjs client provides a good API for sending messages to server through both rest and socket way. But I don't know how to detect a wrong service path in the client side. Let see below code as an example:

const feathers = require('feathers-client')
const Primus = require('../public/dist/primus.js')
var primus = new Primus('http://localhost:3030');
var app = feathers()
  .configure(feathers.hooks())
  .configure(feathers.primus(primus));

var service = app.service('/test-servcie/ssss')

The last line in above code includes a wrong service path (/test-servcie/ssss). A wrong service path means there is no service listening on this path. After that I use below code to send message to service:

service.create({}, {
  query: {
    hostname: 'localhost',
    port: 27017
  }
})

Since the service path doesn't exist, there is nothing happens on the server side. But I also didn't get any wrong message in the client side. How can I know the service path is invalid in client side? I want to show some error messages if the path doesn't exist.

1

There are 1 answers

3
Daff On BEST ANSWER

When using the REST client you will get a 404 or 500 error, unfortunately there is no easy way for websocket libraries to know if the message you are sending is being listened to on the server or not so you will get a timeout (default is 5 seconds) when trying to call any service method in this case. There is a proposal for service introspection which will land in the next version though.