This repository has been archived by the owner on Dec 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing transport fallback in the client
- Loading branch information
moozzyk
committed
Nov 14, 2016
1 parent
97bf8c3
commit 325c909
Showing
3 changed files
with
24 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moozzyk I want to use websockets, but if it fails, at my company the proxy forbids websockets to azure.. it should fallback to long-polling. Should I build this myself? Try to connect websockets and on failure start connection using longpolling? Sorry for asking but couldn't find it anywhere.
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Marcelh1983 - yes - there is no built-in fallback, so you will have to do it yourself. I am thinking about creating a sample somewhere. If this is always going to fail you could disable the transport on the server and the client will pick next available one.
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With always going to fail you mean all connecting clients right? For most clients websockets will work fine, just need a long polling fallback. Will build it :-). Thanks for the reply!
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is what I meant. If all clients would have to always go through a proxy that rejects websockets it might be just easier to disable websockets on the server. When doing fallback make sure you test on Edge/IE because of this.
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reply. I wrote some code that tries to connect and return a promise with the connection on success and an empty promise on fail and tries all different protocols until it has a connection. I think I wrote it ok, but an example would be great because I think lots of people want a fallback protocol.
There are still some issues I experience, I will look into them and maybe the are because its just because its just production ready but maybe you can address these issues immediately.
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put the code in a GitHub repository and we'll take a look.
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have the latest version of the client? This was fixed here: 2a36aa1#diff-ce36dc651371b453b15f91d17a548293R252
The issue is that IE caches responses for xhr requests. Adding the Cache-Control header fixes it for IE11. IE10 and IE9 apparently ignore this header. If people start hitting the issue on IE9/IE10 we can fix it by randomizing the url (this is what ajax from jQuery does).
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using the latest version. I added all ts files in my project and compiled it to es5. I also tried to use the es5 files in the npm package but same result.
I created a repository with a subset of our project, with the fallback (I commented out to test the IE longpolling error). If you start the backend and frontend you'll see IE keep sending connection requests.
Other issue that if I enable my fallback method it still uses longpolling on Azure while it uses Websockets locally. Will deploy this example on Azure tomorrow.
https://github.com/Marcelh1983/signalr-example
signalR service: https://github.com/Marcelh1983/signalr-example/blob/master/Frontend/src/app/shared/services/signalr.service.ts
325c909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #848 for this. Let's use it for further discussion instead of this almost a year old PR.