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

Cannot start() connection to signalR server #9

Closed
davbaron opened this issue Apr 3, 2019 · 3 comments
Closed

Cannot start() connection to signalR server #9

davbaron opened this issue Apr 3, 2019 · 3 comments

Comments

@davbaron
Copy link

davbaron commented Apr 3, 2019

Hello, much like others, I cannot seem to start() a connection to the signalR server. I get back the dreaded Response Content-Type not supported: [application/json; charset=UTF-8]

I looked at the code in dartio_http_client.dart and do not understand some things, specifically with block lines 85 thru 97:

final contentTypeHeader = httpResp.headers["Content-Type"];
final isJsonContent =
    contentTypeHeader.indexOf("application/json") != -1;
if (isJsonContent) {
  content = await httpResp.transform(utf8.decoder).join();
} else {
  content = await httpResp.transform(utf8.decoder).join();
  // When using SSE and the uri has an 'id' query parameter the response is not evaluated, otherwise it is an error.
  if (isStringEmpty(uri.queryParameters['id'])) {
    throw ArgumentError(
        "Response Content-Type not supported: $contentTypeHeader");
  }
}

From what I can tell, the contentTypeHeader variable holds a 'growable list', not a simple string. Thus, when trying to find the 'indexOf("application/json")' if fails (returns -1) instead of returning 0 for the start of the 1st (0th) element in that list. In other words isJsonContent should be TRUE.
image

What's future interesting is that as it stands right now, with a FALSE value, the content is still decoded properly and seems fine. However because there is no 'id' query param in the uri, the code throws the ArgumentError that several of us have hit.

So, what is the solution to this? Is this something that can be fixed?

Thank you,

-David

@davbaron
Copy link
Author

davbaron commented Apr 3, 2019

Uh oh... I just found an item in StackOverflow: https://stackoverflow.com/questions/50980262/how-to-use-signalr-on-flutter

The comment by the Soernt, and the comment after his, seems to imply that this plug in will ONLY work with .Net Core. I am using a .Net frameworks/OWIN site. Does that really mean me (and others like me) cannot use this plug in? In re-reading the README on this repo, it does in fact 'only' say .Net Core.

@soernt
Copy link
Owner

soernt commented Apr 3, 2019

Yes this library is only for .Net Core since Microsoft changed the protocol with .Net Core.

Kind regards,
Sörnt

@davbaron
Copy link
Author

davbaron commented Apr 3, 2019

Thank you for the verification Sörnt. I am now in the process of re-writing (porting) my .net framework web api site to .net core 2.2... hopefully it will not be too much effort and your plug in will then work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants