Hello,
For consistency we tend to put all of our api endpoints in the /api path.
In the case of Server Sent Events, this looks like this:
var ssePlugin = new ServerEventsFeature
{
StreamPath = "/api/events/stream",
HeartbeatPath = "/api/events/heartbeat",
UnRegisterPath = "/api/events/unregister",
SubscribersPath = "/api/events/subscribers",
};
When I connect to the event stream I get this message:
{
"userId": "1",
"isAuthenticated": "true",
"displayName": "user164",
"channels": "*",
"createdAt": "1523028418169",
"profileUrl": "--snip--",
"id": "sYwE8g9DN7eQZC2mampX",
"unRegisterUrl": "http://localhost:63850/api/events/unregister?id=sYwE8g9DN7eQZC2mampX",
"heartbeatUrl": "http://localhost:63850/api/events/heartbeat?id=sYwE8g9DN7eQZC2mampX",
"updateSubscriberUrl": "http://localhost:63850/event-subscribers/sYwE8g9DN7eQZC2mampX",
"heartbeatIntervalMs": "10000",
"idleTimeoutMs": "30000"
}
The updateSubscriberUrl doesn’t match the pattern that I’m using for the rest of the event endpoints.
Is there any way for me to change the default path of the updateSubscriberUrl in a similar manner?
Many thanks!
-Z
mythz
April 6, 2018, 5:54pm
2
I’ve updated the ServerEventsFeature
to use the SubscribersPath
when generating the updateSubscriberUrl
in this commit .
This change is available from v5.0.3 that’s now available on MyGet .
1 Like
Sukram
June 27, 2018, 7:07am
3
Hi Demis,
is this fix also included in 5.1.1 because we have problems with the Server Events JavaScript Clien Lib js/ss-utils.js during UnsubscribeChannels and SubscribeChannels with:
StreamPath = "/eventstream",
HeartbeatPath = "/eventstream-heartbeat",
UnRegisterPath = "/eventstream-unregister",
SubscribersPath = "/eventstream-subscribers",
{
"userId": "1",
"isAuthenticated": "true",
"displayName": "ssePosFeed",
"channels": "VEHICLE_POSITIONS",
"createdAt": "1530082652891",
"profileUrl": "https://raw.githubusercontent.com/ServiceStack/Assets/master/img/apps/no-profile64.png",
"id": "J7B0TUgSnyzWy5y2dJIk",
"unRegisterUrl": "https://uri/eventstream-unregister?id=J7B0TUgSnyzWy5y2dJIk",
"heartbeatUrl": "https://uri/eventstream-heartbeat?id=J7B0TUgSnyzWy5y2dJIk",
"updateSubscriberUrl": "https://uri/eventstream-subscribers/J7B0TUgSnyzWy5y2dJIk",
"heartbeatIntervalMs": "10000",
"idleTimeoutMs": "30000"
}
because we will get 404 not found when calling /eventstream-subscribers/J7B0TUgSnyzWy5y2dJIk ?
mythz
June 27, 2018, 2:17pm
4
Yes v5.1.1 is the latest version. 404 means the subscription is no longer connected which if the client didn’t explicitly disconnect is typically due to server not receiving any valid heartbeats which the server assumes is a lost connection and will automatically unsubscribe the client.
Have a look at the raw HTTP Headers to make sure the heart beats are getting through.
You can also register callbacks in the ServerEventsFeature
OnUnsubscribe
and OnError
delegates to see when the Server unsubscribes the user and if there were any errors, e.g:
Plugins.Add(new ServerEventsFeature {
OnUnsubscribe = sub => ...,
OnError = (sub,ex) => ...
})
Ok we have tested the callbacks and found no errors only if we configure
SubscribersPath = “/eventstream-subscribers”,
instead of “/event-subscribers” we got 404 not found and permanent OnUnsubscribe callbacks but no OnErrors.
mythz
July 2, 2018, 6:53pm
6
This issue might be due to how the updateSubscriberUrl was generated . Can you clear out your NuGet packages cache:
nuget locals all -clear
and download the latest v5.1.1 to see if that resolves the issue?
If not can you provide the raw HTTP Request/Response Headers that’s returning the 404 response.
Im having the same problem but from the typescript package. any ideas?
mythz
March 27, 2019, 12:11am
8
What same problem? please be specific and provide full error details including any HTTP Request/Response Headers (if relevant).
Sorry for the delay. I’m watching a reverse proxy monitor and I see this
GET /api/sse/event-stream - Returns 200
POST /api/sse/json/reply/UpdateEventSubscriber - Returns 404
It appears that only for UpdateEventSubscriber the json/reply is added to the call
var se = new ServerEventsFeature();
se.StreamPath = "/api/event-stream";
se.HeartbeatPath = "/api/event-heartbeat";
se.SubscribersPath = "/api/event-subscribers";
se.UnRegisterPath = "/api/event-unregister";
mythz
March 29, 2019, 11:09pm
10
What base url are you using in the ServerEventsClient
constructor and what is the BaseUrl for your remote ServiceStack instance?
Also why does the route contain /sse/
but it’s nowhere in the custom paths?