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

": Undefined location" when running a manual Mutation (next branch) + Random 127.0.0.1 connections #186

Closed
eliezedeck opened this issue Mar 11, 2019 · 13 comments
Labels
🐛 bug Something isn't working released

Comments

@eliezedeck
Copy link

Describe the bug
When running a mutation manually, I get 2 errors at different code levels:

  • SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 33860 with random port (location is: flutter_graphql/src/link/link_http.dart:85) ... this is directly related to the mutation that I'm trying to run
  • : Undefined location after getting the awaited result of the mutation. Note that my backend is on localhost.

I was trying to get to the code that caused connections to random ports, but I couldn't use the IDE to pin-point the source of the problem. Makes me wonder, why is it doing this random connection and not connecting to where it's supposed to.

To Reproduce
Steps to reproduce the behavior:

  1. Start any project that would use flutter_graphql (same exact behavior when using graphql_flutter's next branch or 1.0.0 beta)
  2. Use an HttpLink that is pointing to a fixed http://localhost:8080/v1/graphql
  3. At this point, any manual mutations I tried to run would cause the same exact error
  4. Even absolutely invalid document will also return the same error
  5. Set a break-point deeper and deeper, and eventually, you'll meet SocketException

Expected behavior
A connection is made to my GraphQL backend. Unfortunately, my backend stays still, not receiving any connection at all.

Screenshots
Here are some screens:

image

image

Desktop (please complete the following information):

  • OS: Linux Mint (based on Ubuntu)
  • Version: 19.1

Smartphone (please complete the following information):

  • Device: Emulator
  • OS: Android
  • Version: any

Additional context
I was looking at the 0.9.5 version, but there was no way to run manual Mutations.

@eliezedeck eliezedeck changed the title ": Undefined location" when running a manual Mutation (next branch) + Random 127.0.0.1 connection ": Undefined location" when running a manual Mutation (next branch) + Random 127.0.0.1 connections Mar 11, 2019
@chirdeeptomar
Copy link

Same Error:
graphql_flutter: ^1.0.0-beta

   final HttpLink link = HttpLink(
      uri: 'http://127.0.0.1:8000/graphql',
    );

    GraphQLClient graphQl = GraphQLClient(
      cache: InMemoryCache(),
      link: link,
    );
    String getAllCustomers = """
          query getCustomers {
            allCustomers {
              id
              name
            }
          }
        """
        .replaceAll('\n', ' ');

    QueryOptions q = QueryOptions(document: getAllCustomers);
    var result = await graphQl.query(q);
    print(result.errors);

@eliezedeck
Copy link
Author

I mean, is this project still alive? At least, a quick reply would be appreciated. Thanks.

@chirdeeptomar
Copy link

Don't think it is....https://github.com/snowballdigital/flutter-graphql but still the same problem!

@yunyu
Copy link
Contributor

yunyu commented Mar 28, 2019

This only occurs when there is an error returned in the mutation, at least with snowballdigital's fork. This catch statement breaks, as the error object is a builtin dart error that has no message getter. If there's no error, the mutation succeeds and the data is returned correctly.

@eliezedeck
Copy link
Author

This only occurs when there is an error returned in the mutation

But that doesn't explain why no connection is made to my GraphQL server, at all.

If there's no error, the mutation succeeds and the data is returned correctly.

Logically, the framework will never know if there was error unless it connects to the GraphQL first.

The main problem here is that the Flutter app using the library never connects to the actual GraphQL server; instead, it tries to connect to random ports. The question of why it does that is still not answered.

@yunyu
Copy link
Contributor

yunyu commented Mar 28, 2019

@eliezedeck I was able to connect to my server fine on both Android and iOS emulators - I'm hosting it remotely, as I was unable to get localhost binding working (in this instance, unless you have a port forwarding setup working, localhost is referring to the actual emulator). I'm fairly sure that the issue you reported happens whenever any error occurs, and we were experiencing separate issues.

Can you connect to your endpoint using just the Dart HTTP client (you may need to try 10.0.2.2 if you're on Android)? If you're unable to, the connection issue is not related to this library.

@micimize micimize added the 🐛 bug Something isn't working label Apr 2, 2019
@micimize
Copy link
Collaborator

micimize commented Apr 2, 2019

@yunyu to be clear, you were unable to connect to localhost:port, even from simulators?
This is probably mostly some kind of firewall or networking issue

The "random ports" can happen as a result of network issues. I'm investigating similar connection issues with iOS. A temporary workaround might be to use ngrok

To keep track of this, here are the environs we're trying to resolve this for:

  • android simulator - setting host to 10.0.2.2is the main candidate solution
  • android device - adb reverse should work
  • iOS device
  • iOS simulator - works for me with localhost and 127.0.0.1 localhost local in my /etc/hosts, idk if there are other configurations I needed to make

@yunyu
Copy link
Contributor

yunyu commented Apr 2, 2019

@micimize It's more of a laziness factor 😢 We didn't bother looking up the 10.0.2.2 and localhost difference for Android and iOS, and somehow ended up using the same one for testing.

That said, I am running into this bug (or at least a variant of it) even when there are no networking issues - errors with a status code of 400 but returning a valid GraphQL response are "eaten" with 400 Bad Request (such as Apollo syntax/data format errors).

@micimize
Copy link
Collaborator

micimize commented Apr 2, 2019

@yunyu exception swallowing is a different issue - at least I'm going to treat it that way, it's kind of a pervasive issue atm but we've got merged changes that should make it better.

Anyways, please provide more details in #177

@yunyu
Copy link
Contributor

yunyu commented Apr 3, 2019

Just kidding, I'm dumb. This is an issue with the current next branch of this library, but not with https://github.com/snowballdigital/flutter-graphql. I just did a quick conversion between the two, and flutter_graphql worked without a SocketError while rev 89fc23c45becd9a8fb90fbede734282941ec531c of graphql_flutter did not.

micimize added a commit that referenced this issue Apr 3, 2019
Check operationName before constructing regex in Operation.isSubscription, fixes #186
@micimize
Copy link
Collaborator

micimize commented Apr 3, 2019

So, I think @yunyu's PR fixed one root cause, and I made #212 for tracking this generally. Closing this, if y'all encounter it again please comment on #212 or make a new issue with more specific details (operation string, port server is running on, environment you're trying to connect from.

@micimize micimize closed this as completed Apr 3, 2019
@HofmannZ
Copy link
Member

🎉 This issue has been resolved in version 1.0.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@HofmannZ
Copy link
Member

🎉 This issue has been resolved in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

5 participants