feathersjs-ecosystem/feathers-react-native-chat

Trouble running example

Closed this issue · 25 comments

Tried running example locally.

npm install
npm start

Then ran the xcode project in ios folder from Xcode. Created account credentials and clicked sign up.
Then the app stalled on creating account...

<View style={{alignItems: 'center'}}>
  <Text>Creating account...</Text>
</View>

I would have assumed there would be some kind of timeout built in? Is that planned?
I guess I need to set up the endpoint or start the server?
Would be nice with some basic instructions :) Thanks.

    this.app.service('users').create(userData).then((result) => {
      this.app.authenticate({
        type: 'local',
        username: this.state.username,
        password: this.state.password
      }).then(response => {
        this.setState({ loading: false });
        // re-route to main authorized chat   component
        Actions.main();
      }).catch(error => {
        console.log(error);
        Alert.alert('Error', 'Please enter a valid username or password.');
        this.setState({ loading: false });
      });
    }).catch((err) => {
      console.log('err');
      console.log(err);
      self.setState({loading: false});
      Alert.alert('Error', err.message);
    });
  }

Trying to locate the socket setup, I see this:

export default class Application extends React.Component {
  constructor(props) {
    // ...
    const options = {transports: ['websocket'], forceNew: true};
    const socket = io('http://192.168.0.1:3030', options);

So it looks like the IP is hardcoded to 192.168.0.1. Which usually is just the IP for localhost
Where is the feathersjs server I wonder? How do I start it? is this another project I need to spin up?

Also, trying to debug from Chrome via localhost:8081/debugger-ui caused a Not available error, as did http://localhost:8081/index.ios.bundle even though I find this in AppDelegate.m.

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

After having tried feathers-chat, I assume that this is just another client for the same server found there :)

Tried starting the feathers-chat server running on localhost:3030, but still getting the same error and no Chrome debug. I'm sure I'm on the right track however...

@kristianmandrup

const socket = io('http://192.168.0.1:3030', options);

Accidentally checked that in, that was when we were testing on device.

I assume that this is just another client for the same server found there :)

Yup!

Let me just check to see what is going on. I may have some changes locally that I forgot to push.

Gracias! Perhaps you/we could detect if the server is up and running (at expected address/port) and display/log an error if not.

@kristianmandrup OMG I forgot to check-in a shit ton of changes so that it works with the chat server. :faceplam:

Pushing up shortly and everything will work MUCH better. Damn, I had been directing people to the app thinking I had pushed the updates.

Sweet :) No worries, happens even for the best! hehe. Very typical

I hope it will include some sort of error handling as well. Would be nice to see some good sample code:
http://docs.feathersjs.com/middleware/error-handling.html

@kristianmandrup ok pushed up the latest. Hope that helps.

I get undefined is not an object, evaluating options.type. Perhaps set it to (options = {}) or even use a default type?

// Application.js#55

      this.app.authenticate().then(() => {
        this.setState({ loading: false });
        Actions.main();
      }).catch(error => {
    app.authenticate = function (options) {
      if (!options.type) {
        throw new Error('You need to provide a `type` attribute when calling app.authenticate()');
      }

@kristianmandrup that has been fixed. Blow away your node_modules in the react native app and re-install. Which version of feathers-authentication do you have installed? You should have v0.5.1.

    "feathers": "2.0.0",
    "feathers-authentication": "^0.5.0",
$ npm install
feathersreactnativechat@0.1.0 /Users/kristianmandrup/repos/react-projs/feathers-react-native-chat
└── feathers-authentication@0.5.1

Sweet :)

run npm ls feathers-authentication what does that output?

Haha :) Now I'm in trouble. I made so many signup attempts last time. Now I'm prompted with login only, but can't seem to find which signup credentials were successful (since no feedback).

How do I blast the nedb back to zero?

@kristianmandrup just rm data/*.db

Well, I found this in the feathers-chat in services/user/index

  const db = new NeDB({
    filename: path.join(app.get('nedb'), 'users.db'),
    autoload: true
  });

Would be nice with the register button as well in case user wants to login/register as another user?

Gracias! Will do.

@kristianmandrup you should be able to register and login as multiple users.

I checked, when I start the server data folder is empty. However I'm still always prompted with "welcome back" and login only. But I can close that window and register again. I see ;)

Wow it WUUURKZzzz!!!! Muchas Gracias!

@kristianmandrup Ya it caches your token. Basically if it detects a previous token stored and the auth attempt fails, it assumes you logged in successfully at some point. So it directs you to the login screen. You can manually clear AsyncStorage or just remove the app from the simulator and rebuild it (or just log in again). Glad you got it working 😄

Yeah! I was working on a similar RN chat app using Firebase and Gifted Messenger.
But this one is beautiful and much simpler :) Inspired!

I also love the filter mechanics of FeathersJS, (currently reading the full ebook). Just what I was looking for. Considering writing a DB adapter for Datomic/Datascript... (clojure land). Cheers!

@kristianmandrup awesome! We are always open to PRs! 😄

Do you have a dev forum of some sort where we can have tech discussions, ideas etc. without bloating up these github issues :P

@kristianmandrup http://slack.feathersjs.com is currently the spot. We also have a public Trello board for the high level roadmap but we've been much more attentive to Github issues and Slack.