GithubHelp home page GithubHelp logo

Comments (14)

zinkkrysty avatar zinkkrysty commented on July 21, 2024

I just tried this now:

alert("Final pusher state: " + pusher.connection.state);

and outputs 'failed'. But the event is not triggered...

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Hiya. Thanks a lot for reporting this. I'm looking into it.

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

By the way, which version of IE are you using?

from pusher-js.

zinkkrysty avatar zinkkrysty commented on July 21, 2024

I think I tried it with both IE9 and IE8 (flash enabled: works; flash disabled: doesn't) through browserstack.com

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Could you tell me which version of the Pusher JavaScript library you are using? Also, are there any error messages displayed in your browser console?

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Sorry. Another question: when do you bind to the failed state? Would you mind posting a little more of your code? It would be useful to see the code from the Pusher object instantiation to the bind?

from pusher-js.

zinkkrysty avatar zinkkrysty commented on July 21, 2024

Hi, I use CoffeeScript and have a static object that holds a method to start listening to different pusher events.

@CarHistoryLookupForm =
  messages_received: 0
  received_anything: false
  pusher: null
  channel: null

  start_listening: (channel_id) ->
    @pusher = new Pusher('xxxxxxx')
    @pusher.connection.bind 'failed', @unsupported
    @channel = @pusher.subscribe(channel_id)
    @channel.bind 'start', (data) => @handle_start(data)
    @channel.bind 'success', (data) => @handle_succes(data)
    @channel.bind 'failure', (data) => @handle_failure(data)
    @channel.bind 'failure_unknown_reg_number', (data) => @handle_reg_number_failure(data)

  # ....

  handle_failure: (data={}) ->
    @disconnect_pusher
    @hide_loader()
    @show_failure()

I call the method from an AJAX response that gets executed (Rails remote form)

CarHistoryLookupForm.start_listening('<%=@channel%>')

if you're not familiar with CoffeeScript, please note that @ means this. and -> or => is similar to function() {

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Great - thank you. Which version of the Pusher JavaScript library are you on?

from pusher-js.

zinkkrysty avatar zinkkrysty commented on July 21, 2024

I was using this one: "http://js.pusher.com/1.11/pusher.min.js"
but I also tried with latest, 1.12 and had the same issue

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Great - thank you. I'll be in touch after I've investigated further.

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

Hmm. I'm a bit baffled. I tried a test with the following code:

var pusher = new Pusher('insertkeyhere');
pusher.connection.bind("failed", function() {
    console.log("failed!");
});

in IE8 running both on a local VM and in browserstack.com and the failed event was emitted correctly. I can't see any important differences between your code and my test code. Is there any way you could send me the URL of your page so I can look at the page source and view any debug console errors that might be getting thrown?

Thanks.

from pusher-js.

maryrosecook avatar maryrosecook commented on July 21, 2024

As we agreed via email, I'm going to close this because we can't reproduce it in isolation from your app.

from pusher-js.

jesussobrino avatar jesussobrino commented on July 21, 2024

Hello!

I have exactly the same problem. I can read in docs (https://pusher.com/docs/client_api_guide/client_connect) I should bind 'error'

So I do the following:

   pusher.connection.bind('error', function (error) {
      console.log('Service error');
    });

    pusher.connection.bind('failed', function (error) {
      console.log('service failed');
    });

    pusher.connection.bind('state_change', function(states) {
      console.log("Pusher's current state is " + states.current);
    });

And when I connect / disconnect my internet connection the only console log I can see is "Pusher's current state is ...". Should I do something else?

Thanks in advance!

from pusher-js.

leggetter avatar leggetter commented on July 21, 2024

From https://pusher.com/docs/client_api_guide/client_connect:

A state of failed means:

Pusher is not supported by the browser. This implies that WebSockets are not natively available, Flash is not available, and an HTTP-based transport could not be found.

This will only every happy at the very start of the connection/Pusher instantiation process.

A state of error occurs:

When connection limits are reached additional connections over the limit will be rejected

Additionally, this may happen if you provide the incorrect application key. This also only happens at the very start of the connection/Pusher instantiation process.

when I connect / disconnect my internet connection the only console log I can see is "Pusher's current state is ..."

As above, this is because both failed and error are initial failure states and you shouldn't expect to see them during the reconnection cycle.

I hope this clarifies things.

from pusher-js.

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.