Connecting to Event Hub - websocket

In my code below I am attempting to create a producer client that i can use to send events to a Event Hub. I am getting a System.PlatformNotSupportedException: 'The WebSocket protocol is not supported on this platform. error Any guidance on how i can resolve this would be much appreciated. FYI my platform is Windows 7, although this program is intended to run on a windows 2008 server or later.
var producerOptions = new EventHubProducerClientOptions
{
ConnectionOptions = new EventHubConnectionOptions
{
TransportType = EventHubsTransportType.AmqpWebSockets,
},
RetryOptions = new EventHubsRetryOptions
{
MaximumRetries = 5,
TryTimeout = TimeSpan.FromMinutes(1)
}
};
var producer = new EventHubProducerClient(connectionString, eventHubName, producerOptions);
//here is where the error occurs. which is inside a try - catch block
var eventBatch = await producer.CreateBatchAsync();
......

The Event Hubs client library relies on the underlying framework for its transport communication. In this case, it sounds as if you're using the full .NET Framework on Windows 7, where web sockets is not supported.
So long as your aren't using a UWP application, changing the target framework to .NET Core and using the netstandard2.0 target from the client library may work. (see: this PR)
More detail can be found in the accepted answer for this question, which also contains some advice for third party packages that may work as a polyfill.

Related

How to receive private messages from the stream using Socket.IO in .Net Core 3.0

I am trying to receive private meesages from SocketIO stream. I have IP address but I am getting problem in connection. Also, if connection will happen then also I have to authorize the connection using token then only I can get the messages. I dont how to implement this as I am vey much New to this thing.
I have tried with the following code from the stack overflow but no luck yet.
Also, can anybody tell me which library is best to use:
SocketIO4Net.Client
SocketIOClientDotNet
I am using 2nd one.
var socket = IO.Socket("myip");
socket.On("xx", async (data) =>
{
var test = await Update(data.ToString());
});
Can anybody help me on this. I am .net server side developer.Thanks in advance!!

Using Sinch with Xamarin

I'm targetting iOS and Android platforms for a messaging application.
I want to use voice and messaging features of the sdk.
Are there any bindings available for sinch sdk for xamarin?
Sinch has a C# wrapper for sending SMS via their REST interface. It is available via a Nuget (Sinch.SMS) and/or you can grab the code on Github; https://github.com/sinch/Sinch.SMS
i.e. (from their hello world example):
To send an SMS use:
var client = new Sinch.SMS.Client("yourkey", "yoursecret");
var messageid = await client.SendSMS("+46722223355", "hello from sinch");
To check a status of an SMS use:
var client = new Sinch.SMS.Client("yourkey", "yoursecret");
var result = await client.CheckStatus(messageid);
As far as a complete SDK bindings for their Android/iOS SDKs, I do not know of one personally.
I 'just' would import them into XStudio and convert their sample call apps and give it a try. Should not take very long to see if the auto-wrappers work. Otherwise you would have manually correct/write the C# bindings to their 'native' lib
Here are some Xamarin binding libraries available on nuget. They are by a Vietnamese Software Development company called NAXAM. I believe these are all open source, and published on their github here: https://github.com/NAXAM
https://www.nuget.org/packages/Naxam.SinchVoice.Droid/
https://www.nuget.org/packages/Naxam.SinchVoice.iOS/3.11.0-pre1
https://www.nuget.org/packages/Naxam.SinchVerification.Droid/
https://www.nuget.org/packages/Naxam.SinchVerification.iOS/2.0.4-pre1

WebSockets + Haxe?

I need to develop an application using WebSockets and Haxe.
I came upon this lib: http://lib.haxe.org/p/hxWebSockets
But it's outdated.
Then I found this blog post: http://bp.io/post/322
But the links to the code are broken :(
So, anyone out there knows any other WebSocket resource for Haxe?
If not, does someone has a clue where to start looking to start implementing my own solution?
Thanks!
If you use node.js as a platform, I'd recommend you to make bindings to socket.io. If you use another platform, I'd recommend to use socket.io as a reference implementation, or just port it to haxe, which shouldn't be that hard.
The lib you mentioned is indeed outdated. Luckily, someone made a new one, supporting the latest websocket protocol:
http://lib.haxe.org/p/WebSocket
...however, it's still a bit lower level than nodejs/socket.io
I am using haxe for a websockets application and using the js libraries:
import js.html.WebSocket;
Using the following function to connect to the server.
private function connect() {
trace("Calling connect");
try {
websocket = new WebSocket(connectionString());
websocket.onclose = onClose;
websocket.onerror = onServerConnectionError;
var openStream = initializeElementStream(cast websocket, "open");
openStream.then(onOpen);
var eventStream = initializeElementStream(cast websocket, "message");
eventStream.then(onMessage);
var closeStream = initializeElementStream(cast websocket, "close");
closeStream.then(onClose);
var errorStream = initializeElementStream(cast websocket, "error");
errorStream.then(onServerConnectionError);
}catch(err : Dynamic) {
trace("Error establishing connection " + err);
}
trace("Connection successful");
}
Will this work for you. I am sticking to standard js libraries for my project. This has worked for me since the project has no external dependencies.
I recently started using Haxe-Js-Kit and it has decent bindings for a lot of nodejs libs including Socket.IO.
https://github.com/clemos/haxe-js-kit/
Make sure you use the dev branch for development as it is quite more advanced than the haxelib or master branch.

Accessing Azure with a CloudStorageAccount

I have Console application which submit messages to Azure queue. Now I am trying to migrate this application to Mobile, but met reference problem with CloudStorageAccount. It requires Windows dll version but mine is Mobile.
Do you guys have any idea how I can initialize CloudStorageAccount object alternative way?
public Initializator()
{
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
// for a console app, reading from App.config
configSetter(ConfigurationManager.ConnectionStrings[configName].ConnectionString);
});
CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("QueueStorage");
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
queueIn = queueClient.GetQueueReference("queuein");
queueOut = queueClient.GetQueueReference("queueout");
queueIn.CreateIfNotExist();
queueOut.CreateIfNotExist();
}
One of the easiest ways, in my opinion, to work with Windows Azure storage (tables, blobs, & queues) from Windows Phone is to use the Phone.Storage NuGet package (http://www.nuget.org/packages/Phone.Storage). This makes working with storage on the phone nearly identical to working with storage from a server (or console app).
Be sure to check out Wade Wegner's blog post at http://www.wadewegner.com/2011/11/nuget-packages-for-windows-azure-and-windows-phone-developers/ for some additional info on the NuGet packages.
There's also a Phone.Storage.Sample package that may be worth taking a look at.

Communication between C# running on Windows and C running on linux with protobuf

I have a server application running on Linux. This application was
developed using protobuf c and protobuf.rpc.c files for RPC communication.
I have a client application which was running on windows.It was developed in c# using protobuf-net.dll and ProtobufRemote.dll for RPC communication.Both application using the same proto file having same service methods.
I can able to create a proxy from C# client application with the below code.
using System.Configuration;
using System.Net.Sockets;
using ProtoBufRemote; // rpc reference
using StarCall; // proto file
#region Create client connection
Int32 port = Convert.ToInt32(ConfigurationManager.AppSettings["PORT"]);
TcpClient tcpClient = new TcpClient(ConfigurationManager.AppSettings["SERVERIP"].ToString(), port);
var controller = new RpcController();
var client = new RpcClient(controller);
var channel = new NetworkStreamRpcChannel(controller, tcpClient.GetStream());
channel.Start();
var service = client.GetProxy<Istarcall_services>();
if (service == null)
Console.WriteLine("error creating client..");
//now calls can be made, they will block until a result is received
Console.WriteLine("Client connected to Server....\n");
#endregion
But whenever I am trying to invoke a service method from C# client application as shown below, the application is hanging and not getting any response from Linux c server application.
try
{
Room_Config room = new Room_Config();
room.Room_Dial_Num = 1;
Room_Config roomRet = service.read_room(room); // service method
}
catch (Exception)
{
throw;
}
The application is hanging in the below code.
protected RpcMessage.Parameter EndAsyncCallHelper(string methodName, IAsyncResult asyncResult)
{
PendingCall pendingCall = (PendingCall)asyncResult;
pendingCall.AsyncWaitHandle.WaitOne(); // application hanging here
pendingCall.AsyncWaitHandle.Close();
if (pendingCall.IsFailed)
throw new InvalidRpcCallException(serviceName, methodName,
String.Format("Server failed to process call, returned error message: \"{0}\".",
pendingCall.ServerErrorMessage));
return pendingCall.Result;
}
According to above mentioned scenarios, I have the following queries.
Whether this protobuf remote c# dll can help to create a communicatgion from the linux c code. If not please help me how to create a communication channel with the linux c code.
Please provide if any alternative rpc dll for c# client application to communicate to linux protobuf c and protobuf rpc.c file.
Please tell me if my above approach is wrong and rectify with the suitable solution.
Please help me out. If not clear please send to mail mentioned below.
Have you implemented your server in Linux with ProtoBufRemote cpp available at https://code.google.com/p/protobuf-remote/ ??
If yes, then you must have replaced or modified SocketRpcChannel.cpp class as it is using WinSock2 that is not applicable on Linux.
Have you done so? If yes, please share modified SocketRpcChannel class that you have used in your server.
Thank you.

Resources