Code Monkey home page Code Monkey logo

graphql_ws_client's People

Contributors

tlux avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

graphql_ws_client's Issues

prevent `Driver.parse_message/2` being called without `Conn`

     18:04:32.606 [error] GenServer #PID<0.830.0> terminating
     ** (FunctionClauseError) no function clause matching in GraphQLWSClient.Driver.parse_message/2
         (graphql_ws_client 0.1.1) lib/graphql_ws_client/driver.ex:82: GraphQLWSClient.Driver.parse_message(nil, {:gun_error, #PID<0.831.0>, #Reference<0.1050648357.2088501250.11223>, {:closed, :normal}})
         (graphql_ws_client 0.1.1) lib/graphql_ws_client.ex:509: GraphQLWSClient.handle_info/2
         (connection 1.1.0) lib/connection.ex:810: Connection.handle_async/3
         (stdlib 4.3) gen_server.erl:1123: :gen_server.try_dispatch/4
         (stdlib 4.3) gen_server.erl:1200: :gen_server.handle_msg/6
         (stdlib 4.3) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
     Last message: {:gun_error, #PID<0.831.0>, #Reference<0.1050648357.2088501250.11223>, {:closed, :normal}}

Halt on GraphQLError in Stream

At the moment, the iterator exits which probably is a bit error prone. Instead we should rather halt and log the error (the latter is something we are already doing)

Add option `:resubscribe_on_reconnect`

When the connection is terminated by the server, all listeners get notified that the socket has been closed. However, in some cases (for example if the client is running as part of the application supervision tree) it may be desirable to automatically restore all subscriptions when the connected is reopened. That means, we have to store all subscription queries and the associated listener processes in the client state and re-send all subscriptions right after the connection is restored.

Hence, I would like to introduce the :resubscribe_on_reconnect config option.

We need to keep in mind, that graphq-ws sockets prohibit to reuse a subscription ID unless the old subscription was removed. So we should make sure that the old subscription is removed before resubscribing with the same ID.

Improve query timeout handling

At the moment a query timeout will lead to reconnection. Instead we should remove the timed out query from the state, reply to the caller that the call timed out (%SocketError{cause: :timeout}) and ignore any messages that arrive after the timeout. We should probably also explicitly unsubscribe after a read timeout by sending a complete message to the socket.

Subscriptions in constrast should never time out.

:gun_down message not handled

We need to handle :gun_down messages like these or else the Gun driver will fail in parse_message/2:

{:gun_down, #PID<0.831.0>, :ws, :normal, [#Reference<0.2401964237.290979843.123374>]}

Resubscribe automatically when connection lost

  • Add option :resubscribe_on_reconnect
  • Resubscribe only when disconnect occurred due to an error
  • Alternatively, notify all subscriptions that the connection was lost so that they can resubscribe manually

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.