public Task<string> OpenAsync(CancellationToken cancellationToken)
var serviceEndpoint = this.serviceContext.CodePackageActivationContext.GetEndpoint(this.endpointName);
int port = serviceEndpoint.Port;
var protocol = serviceEndpoint.Protocol; // <- UPDATED
if (this.serviceContext is StatefulServiceContext)
StatefulServiceContext statefulServiceContext = this.serviceContext as StatefulServiceContext;
this.listeningAddress = string.Format(
CultureInfo.InvariantCulture,
"{0}://+:{1}/{2}{3}/{4}/{5}", // <- UPDATED
string.IsNullOrWhiteSpace(this.appRoot)
: this.appRoot.TrimEnd('/') + '/',
statefulServiceContext.PartitionId,
statefulServiceContext.ReplicaId,
else if (this.serviceContext is StatelessServiceContext)
this.listeningAddress = string.Format(
CultureInfo.InvariantCulture,
"{0}://+:{1}/{2}", // <- UPDATED
string.IsNullOrWhiteSpace(this.appRoot)
: this.appRoot.TrimEnd('/') + '/');
throw new InvalidOperationException();