SignalR - No connection could be made because the target machine actively refused it?

Posted by user2151460 on Stack Overflow See other posts from Stack Overflow or by user2151460
Published on 2014-08-22T16:15:58Z Indexed on 2014/08/22 16:20 UTC
Read the original article Hit count: 1162

Filed under:
|

Trying to create a Console application that is going to send data to a website. The website is built with Codeiginter framework, if that matters.

When i'm running my Console application, i get the error that a connection could not be made, and that the machine refused it.

Been watching some tutorials, but most of them are using Hubs etc, which imo i do not need for this simple task?. All i want to do is to send data to the website, one way.

Here is my Console application

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Client;

namespace signalrDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var connection = new Connection("http://localhost:3000/servers/2");

            connection.Received += data => Console.WriteLine(data);

            connection.Start().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Console.WriteLine("Failed to start: {0}", task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Success! Connected with client connection id {0}", connection.ConnectionId);

                }
            });

            Console.ReadLine();
        }

    }
}

And at my website, i have this code

    $(function () {


        var connection = $.connection('http://localhost/servers/2');

        connection.received(function (data) {

            $("message").append(data + '<br />');

        });


         connection.start().done();



    });

Thank you.

© Stack Overflow or respective owner

Related posts about signalr

Related posts about signalr.client