Ionic 2 signalr is not connecting with hub

2019-07-11 06:23发布

i am using library 'signalr-no-jquery' in ionic2 with 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 ?

Library link:

https://github.com/DVLP/signalr-no-jquery

I have searched but did not find any solution . Any suggestion?

Note: At server side i'm using c# web api . and hub is configured and it's working fine with angular1 as a client.But same is not working with my ionic2 app.

Update 1

Here is chrome network response .

Request 1

Request URL:

http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//192.168.0.213%3A9000/signalr/negotiate%3FclientProtocol%3D1.5%26connectionData%3D%255B%255D

Response:

Request 1 response

Request 2

Request URL:

http://localhost:4400/ripple/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=http%3A//192.168.0.213%3A9000/signalr/connect%3Ftransport%3DlongPolling%26clientProtocol%3D1.5%26connectionToken%3DCfDJ8HpWfXipicxHvZ8CCLKyWJkObE4lFrYrJehJly%252BSs8%252BNamgEaPH0GDQkZlsZXuYxn32TZOpm4cmPzLeOYq1zTPBXpU5sxK3pF%252FONkllddO1ivhI2hur79Hr4YWVYJ45K7Bukm2R2JZXtn0FF%252FFOtl798xyA7i4UL1Ufz4ZfkAOsN%26connectionData%3D%255B%255D

Response

The ConnectionId is in the incorrect format.

[1]: https://github.

0条回答
登录 后发表回答