-
Notifications
You must be signed in to change notification settings - Fork 445
UnexpectUnexpected token G in JSON at position ed token G in JSON at position #1107
Comments
@larserikfinholt - how do I repro this? I am running the ChatSample quite often and have not seen this. There must be something missing in both reports which makes it hard to figure out what the problem is. Can you run your app with Kestrel only and turn on logging at the Trace level on the server and paste the logs? Do you see any errors/warnings in the logs? |
Sorry, I see no trace of the request hitting the server. Maybe there's something with the request thats beeing sent. It looks like this:
In addition I have the following:
|
@moozzyk I'm dealing with the same problem, and here's what the response to payload negotiation request in HttpConnection.ts looks like, in my case: HTTP/1.1 200 OK Is it possible that the OPTIONS request to the hub is not being intercepted by the SignalR middleware? |
@gateway7 - Doesn't the header |
@larserikfinholt - how does the response look like? Did you run Kestrel without anything (IIS/nginx) in front of it? Can you check if you did not get a cached response (e.g. from the browser's cache)? |
@moozzyk - client talks to directly to the service (no reverse proxies involved), which is hosted by Kestrel on Windows 10. I've no idea how expressjs got into the picture. |
@gateway7 - can you try to figure out who is writing this header, whether the request actually hits the server at all, or if the response is coming from the browser's cache (look at the network tab in the developer tools)? btw. what browser do you use? I wonder if we need to add |
@gateway7 @larserikfinholt - can you check if things start working if you add some random querystring to your url (e.g. |
|
Have you ever run an Express-based app at the same URL (including port)? I think Chrome may aggressively cache CORS pre-flight data (i.e. That would indicate that we should avoid using |
@anurse |
Closing this out |
@moozzyk @davidfowl I'm really embarrassed to say this but I actualy tried to connect to the webserver that serves my SPA, not to the webapi. I could easily have spotted this looking at the OPTIONS request to /multiplayer, instead of http://localhost:5005/multiplayer. Fixed by starting the connection with
Again, sorry for raising such a dumb issue. |
@larserikfinholt 😆 No worries, we've all done things like that. Glad to hear you got it working properly in the end! |
Made same mistake. It's better add some information to the document, or some comment to the sample code. |
I am having the same problem as @gateway7. Any solution while still using |
Can you confirm your configuration? What ASP.NET Core server are you using (Kestrel/IIS/etc.)? Can you look at the response you are getting the error from? It's likely an HTML page which may provide more information about the reason for the error. |
I am using Kestrel, and the Response is sending back "GET, HEAD". I am running my Angular SPA on a separate server, but my connection string for HubConnection specifies the correct port (5000), so it's not the issue @cuiliang was dealing with. |
We did that in the preview 1 build. We don't patch or update old preview builds once the new one is released. You'll have to update to ASP.NET Core 2.1 Preview 1 to get the fix. |
@anurse Yeah, I figured. Now I just have to convince my team to upgrade... |
@anurse Before I make my case, do you have any idea why the OPTIONS negotiate request doesn't work? Is there any solution? |
Do remember that our preview releases come with no guarantee of support. You should keep as current as possible during preview releases, because as soon as RTM is out, that'll be the only supported version. Also, we could really use the feedback. We recognize that upgrading between released versions can be difficult, but for preview releases, we strongly recommend you keep up-to-date, otherwise we won't be able to solve any problems you do encounter in time for RTM. |
@anurse You have been very gracious with your time; perhaps you can help. I upgraded, and now the response from the negotiate request is indeed some HTML. It says |
This seems very strange, there's nothing in ASP.NET Core that would produce this error as far as I'm aware. Are you sure you're connecting directly to your ASP.NET Core application and not to an intermediate proxy (such as Angular tools, etc.)? If you're using a relative URL, it might not be working properly, I suggest checking the Network tab of your browser dev tools and verifying that it's actually connecting to the SignalR endpoint. If it is connecting to the right endpoint, you should check if you have any middleware above the |
I have tried very hard to figure out what's going wrong, but I got nothing. |
I GOT IT! |
No problem! Glad you got it sorted out! |
It seems like the OPTIONS request to the hub returns "GET, HEAD" instead of an object. I think this issue is related, #1033
I've tried both IIS Express, and kestrel on win 10. There's an other user at SO with a similar issue: https://stackoverflow.com/questions/46825533/getting-error-while-trying-to-use-signalr-in-angular4-netcore-2-0-application
I'm using a plain mvc web app based on the chat sample in this sln https://github.com/aspnet/SignalR/tree/dev/samples/ChatSample
The text was updated successfully, but these errors were encountered: