Giter VIP home page Giter VIP logo

Comments (5)

Workshop2 avatar Workshop2 commented on August 24, 2024

Hey @kinetiq
Do you have a code example anywhere I could try? Are you running through a proxy?

Thanks

from slackconnector.

kinetiq avatar kinetiq commented on August 24, 2024

No proxy, just running this in a simple setup at home.

Code is very simple:

        var connector = new SlackConnector.SlackConnector();
        Connection = await connector.Connect(slackKey);
        Connection.OnMessageReceived += MessageReceived;
        Connection.OnDisconnect += OnDisconnect;

Also! If I go into your code and change this line to synchronous, everything works:

        IRestResponse response = client.ExecuteAsPost(request, "post");

...The handshake succeeds, and I end up getting events and so on! Any idea what this might be?

from slackconnector.

Workshop2 avatar Workshop2 commented on August 24, 2024

Is your console app method async? I have seen these kind of issues before when trying to await something when not in an async context.

Could you do something like:

        var connector = new SlackConnector.SlackConnector();
        Connection = connector.Connect(slackKey).Result;
        Connection.OnMessageReceived += MessageReceived;
        Connection.OnDisconnect += OnDisconnect;

from slackconnector.

kinetiq avatar kinetiq commented on August 24, 2024

You are right, I wasn't in an async context! I was doing this:

    static void Main(string[] args)
    {
        MainAsync(args);        
    }

    static async void MainAsync(string[] args)
    {
        var manager = new ConnectionManager();
        await manager.Connect();

        Console.ReadLine();
    }

But I needed to do this:

    static void Main(string[] args)
    {
        MainAsync(args).Wait();
    }

    static async Task MainAsync(string[] args)
    {
        var manager = new ConnectionManager();
        await manager.Connect();

        Console.ReadLine();
    }

Dumb mistake, clearly need to do more async work.

I bet people run into this a lot when they're getting started. I actually bounced off of this problem once before, months ago, and I'm just now playing with it again.

Anyway! Thanks for the help.

from slackconnector.

Workshop2 avatar Workshop2 commented on August 24, 2024

No problem, glad to have helped

from slackconnector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.