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

System.UriFormatException: 'Invalid URI: The hostname could not be parsed.' #1

Open
azimbialiev opened this issue Jun 2, 2019 · 0 comments
Assignees

Comments

@azimbialiev
Copy link

azimbialiev commented Jun 2, 2019

I'm stuck with an error when trying to connect to a private channel using my remote authorizer.

This is my Authorizer:
```
class CustomAuthorizer : IAuthorizer
{
private Uri _authEndpoint;
public CustomAuthorizer(string authEndpoint)
{
_authEndpoint = new Uri(authEndpoint);
}

	public string Authorize(string channelName, string socketId)
	{
		string authToken = null;

		using (var webClient = new System.Net.WebClient())
		{
			string data = String.Format("channel_name={0}&socket_id={1}", channelName, socketId);
			//webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
			//webClient.Headers[HttpRequestHeader.Accept] = "application/json";
			webClient.Headers[HttpRequestHeader.Authorization] = App.UserAPI.GetBerarer();
			try
			{
				authToken = webClient.UploadString(_authEndpoint, "OPTIONS", data);

			}
			catch (Exception e)
			{
				Logger.Log(this, nameof(Authorize), e);
			}
		}
		return authToken;
	}
}


I pass this Uri to the constructor: http://mng-mobile.it/broadcasting/auth
And Uri get parsed correctly.

Then I initialize PurePusherClient:

public void Init()
{
var auth = new CustomAuthorizer(AppConfig.PUSHER_AUTH);
var options = new PurePusherClientOptions()
{
Authorizer = auth,
Encrypted = true,
};
this.Pusher = new PurePusherClient(AppConfig.PUSHER_APP_KEY, options);
Pusher.Connected += Pusher_Connected;
Pusher.ConnectionStateChanged += Pusher_ConnectionStateChanged;
Pusher.Error += Pusher_Error;

		Pusher.Connect();

	}

I'm getting System.UriFormatException: 'Invalid URI: The hostname could not be parsed.'
on Pure.Connect().
StackTrace:

error System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at PureWebSockets.PureWebSocket.Connect()


Can someone help to fix this problem?
@ByronAP ByronAP self-assigned this Aug 4, 2019
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