inProgress-team / inProgress-team/react-native-meteor

Meteor.connect does not connect

Open
#170 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
688
Forks
200
PR merge metrics
No merged PRs in 30d

Description

Hi!

Looking forward to using this library for my current project. Unfortunately I can't seem to connect to my meteor server. This is how my code looks like

```
componentWillMount() {

Trackr.autorun((c) => {
if (c.firstRun)
return

console.error(Meteor.status().connected)
})

// https://developer.android.com/studio/run/emulator-commandline.html#networkaddresses
Meteor.connect('ws://10.0.2.2:3000/websocket')
}
```

The autorun is only called on firstRun, Meteor.status() is never updated.

Then, I have tried this:

```
Meteor.connect('ws://10.0.2.2:3000/websocket')
console.error(Meteor.status().connected)
```
Which results in `false` => I am not connected

Just to be sure, I installed `ddp-client` then and did this:

```
let ddpclient = new DDPClient({
url: 'ws://10.0.2.2:3000/websocket'
});

ddpclient.connect((error, wasReconnect) => {

if (error) {
console.log('DDP connection error!');
return;
}

if (wasReconnect) {
console.log('Reestablishment of a connection');
}

console.error('Connected!');
});

```

And voilà: I get a successful `Connected!` message

So there does not seem to be an error with my connection url, the meteor server seem to also be reachable.

What am I doing wrong then? What is the difference between `Meteor.connect` and `ddpclient.connect`?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.