Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not connection SignalR error: undefined #11

Closed
EmreMengukan opened this issue Nov 25, 2016 · 4 comments
Closed

not connection SignalR error: undefined #11

EmreMengukan opened this issue Nov 25, 2016 · 4 comments

Comments

@EmreMengukan
Copy link

signals system => html page connection to signalr no problem alone react-native-signalr plugin there is an error

Back end code

[assembly: OwinStartup(typeof(Statistics.Startup))]
namespace Statistics
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
           
            app.UseCors(CorsOptions.AllowAll);
            app.MapSignalR();
        }
    }
}

namespace Statistics
{
    [HubName("dataHub")]
    public class DataHub : Hub
    {
        public void Send(object obj)
        {
            Clients.All.broadcastMessage(obj);
        }
    }
}

html code

<script src="Scripts/jquery-1.6.4.js"></script> <script src="Scripts/jquery.signalR-2.2.1.js"></script> <script src="signalr/hubs"></script>

$(function() {
        var chat = $.connection.dataHub;
         chat.client.broadcastMessage = function ( message) {
            console.dir(message)
        };

        $.connection.hub.url = "http://myserverurl/signalr/hubs";
        $.connection.hub.start().done(function() {
                 chat.server.send('test sample');
        });
    });

html connection no problem

react-native code

import signalr  from "react-native-signalr";


componentDidMount(){



        var connection = signalr.hubConnection('http://myserverurl/signalr/hubs');

        connection.logging = true;

        var proxy = connection.createHubProxy('dataHub');
 
        proxy.on('broadcastMessage', (message) => {
            console.log(message);

        });



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



        console.log(connection.connectionState)

            connection.connectionSlow(function () {
                console.log('We are currently experiencing difficulties with the connection.')
            });

            connection.error(function (error) {
                console.log('SignalR error: ' + error)
            });

    }

react native chrome debuger console error log ;

ekran resmi 2016-11-25 10 50 17

Example project can you share Help Me :)

@olofd
Copy link
Owner

olofd commented Nov 25, 2016

@EmreMengukan You need to enable support for http (non-encrypted connection) in xcode. xcode has this disabled by default

@olofd
Copy link
Owner

olofd commented Nov 25, 2016

@olofd
Copy link
Owner

olofd commented Nov 25, 2016

Locate your Info.plist (resides in the ios folder) and add this:

	<key>NSAppTransportSecurity</key>
	<dict>
		<key>NSAllowsArbitraryLoads</key>
		<true/>
	</dict>

Let me know if this does not work.

@EmreMengukan
Copy link
Author

@olofd You are the best 👍 :))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants