DVLP / signalr-no-jquery

120 stars 78 forks source link

Not connecting with Hub. #20

Closed Usman235 closed 5 years ago

Usman235 commented 7 years ago

In ionic2 in visual studio 2015 . I'm using the following code .

Import:

import { hubConnection } from 'signalr-no-jquery';

Code:

        console.log("Stage 1");
        var connection =new  hubConnection('http://192.168.0.213:9000');

        console.log("Stage 2");

        var hubProxy = connection.createHubProxy('broadcaster');
        console.log("Stage 3");

        connection.start({ jsonp: true })
            .done(() => {
                console.log('Now connected, connection ID=' + connection.id);

            })
            .fail(() => { console.log('Could not connect'); });

Every time it goes in fail and write console 'Could not connect'. Any suggestion what i'm doing wrong ?

sateffen commented 7 years ago

Does your backend support jsonp? You configured it to only use jsonp, so your backend has to support it.

As well: Did you whitelist the IP in cordova? An obvious thing, but some people actually forget about this.

Usman235 commented 7 years ago

@sateffen thanks for response.

Same code is working fine on Device when i run on Ripple Emulator its not working.

gtwilliams03 commented 7 years ago

I removed the { jsonp: true } option in connection.start() and mine connected.