SharpSnmpLib how to receive SNMP traps with any community - c#

I'm trying to use SharpSnmpLib for dotnet 6.0 project.
SharpSnmpLib.Engine 12.0.0 was installed via nuget.
I get some snippet of code from samples from github repo
https://github.com/lextudio/sharpsnmplib-samples
and while community in sender and listener match it work all right.
But in real world, equipment sends traps (version v2c) with community like public#eventId=16#20230125110210
In listener community is set by this line of code (from samples)
var v2 = new Version2MembershipProvider(new OctetString("public"), new OctetString("public"));
Even for traps version v1 if I change trap community to "public1111" listener could not receive it.
Is there any possibility to accept traps with any community? Set getter to something like "any" or "*" ? Or maybe the problem is not here and changes should be made somewhere in authentication?

Related

How can I open a connection to "Coinex" websocket using "WebSocketSharp" in C#

I'm currently working om my very own trade bot and I want to stream realtime cryptocurrency price from coinex.com using websocket (documentation is here: "https://github.com/coinexcom/coinex_exchange_api/wiki").
I start with a windows form project in Visual Studio and add websocketsharp Nuget package to make a connection using this two lines of code:
WebSocket ws = new WebSocket("wss://socket.coinex.com/");
ws.Connect();
but connection is not stablished and I can't continue working on other parts of my program.
after a week searching and googling I have no success. I appreciate any help to solve this problem.
I find the problem. The Coinex.com domain restricted (Blocked) here (In IRAN) and I should use Proxy to bypass restriction. But here there is another problem: How can I set Proxy for websocketsharp? there is a "Setproxy" function in "websocketsharp" but do not work.

NullReferenceException inside Couchbase client 3.0 during connection

I am working on migration from .NET SDK 2.7 to .NET SDK 3.0. Couchbase server 6.0.
This code throws NullReferenceException. I can't understand what I am doing wrong. I can't put the exception call stack. The site tells me that I have too much code or exception should be marked as code.
var options = new ClusterOptions()
.WithConnectionString("http://192.168.1.120:8091") //Node's IP
.WithCredentials("User", "Password")
.WithBuckets("SomeBucket");
var cluster = await Cluster.ConnectAsync(options);
It was a problem in SDK and it was fixed in 3.0.2. But right now I am getting the same error on getting buckets. So need to wait for the new SDK version again :-)
Update
Some more details u can get here.
Shortly. Remove the port and all will be more or less OK.

EchoDot is unable to request my skill tough it works in web interface

I just tried to develop a skill for Alexa in C#. It just consits out of a simple intent with a slot for a name and says something like "Hi {name}" as response.
I created an AWS Lambda project in visual studio, referenced alexa skills for .Net core by Tim Heuer and implemented the intent:
var name = intentRequest.Intent.Slots["name"].Value;
var speech = new Alexa.NET.Response.SsmlOutputSpeech {Ssml = $"Hallo {name}. Schön dich zu sehen."};
response = ResponseBuilder.Tell(speech);
response.Response.ShouldEndSession = true;
I published it into my AWS Lambdas via Visual Studio AWS Toolkit, added Alexa as a trigger and created the Alexa skill and referenced it to the lambdas arn.
I enabled the skill for my own echo dot device, I also can see it exists in my app. If I now ask the echo dot to launch the skill I just get an error saying "An error occurred during the response of the requested skill" (translated from German). But if I test the skill in the Alexa developer website on Amazon it all works fine. Same if I test it in visual studio itself.
Skills in general work on my echo dot (also the node js trivia game example). What might cause this problem? Is this an error in my lambda function?
I finally found out that the SsmlOutputSpeech was the problem. Seems like you have to fill in the string in Ssml syntax, even it wasn´t done like this in the related GitHub repository. I just moved to PlainTextOutputSpeech as this is enough for my cases.

SerialPort.GetPortNames() returns incorrect port names

While c# is not my primary programming language, I'm maintaining such a program for a couple of years now. This program connects to a device on a serial port and works from Windows XP up to 8.1. One specific "feature" is that it uses .NET Framework 2.0.
With some users upgrading to Windows 10 we've got complains that the program cannot detect/open the COM port of the device. We have confirmed this on our own test systems with clean Win10 installation.
It turns out that the function SerialPort.GetPortNames() returns incorrect port names and adds 'strange' characters after the port name.
For example:
COM3吀
COM3䡢
COM3゠
Etc. When I refresh the list, every time another character (or two) shows up after the number.
The test code is super straightforward:
string[] portNames = System.IO.Ports.SerialPort.GetPortNames();
log("Available ports:");
foreach (string PortAvailable in portNames)
{
log(PortAvailable);
}
Where the log function mearly adds a line to a standard TextBox on the form:
txtLog.Text += Msg + Environment.NewLine;
This works in every other Windows version.
I've checked the registry and all looks fine there also.
Does anybody has an idea about this?
I'm suspecting that .NET Framework 2.0 is not 100% compatible anymore, although you can enable it in the Windows features and it seems that the program itself runs fine (besides my serial port problem). I'm a bit scared to upgrade to a newer .NET, let alone that we've VisualStudio 2008 for c# (max=.NET 3.5). Note that the program still needs to run on Windows XP also (POS version is still maintained by Microsoft).
ADDED:
I've "upgraded" a test program to .NET 3.5, and still having exactly the same issue.
Next step is to install a new VisualStudio (it appears that it is free nowadays?? Should I check for privacy settings in Studio also? ;-).
ADDED 2:
Installed VisualStudio 2015 and made multiple builds with different .NET framework versions. v2.0 and 3.5 still adding the strange character. But in v4.0 and up this issue seems te be solved! Now to get the original program compiled and working for the newer Framework.
But I find this issue really strange and would expect that this would hit more .NET functions and more programs.
I've seen the strange characters too. My solution is using Regular Expressions to filter out the number portion of the comm port name.
Dim ports As New Devices.Ports
For Each s As String In ports.SerialPortNames
s = Regex.Replace(s, "\D*(\d+)\D*", "$1")
Debug.WriteLine(s)
Next
I've had this exact same problem with USB CDC serial devices, handled by the new rewritten Windows 10 usbser.sys driver.
The garbage characters are often digits, so removing non-digits isn't a reliable way to work around it. For my solution, look at my last post on this thread here:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/a78b4668-ebb6-46aa-9985-ec41667abdde/ioportsserialportgetportnames-registrykeygetvalue-corruption-with-usbsersys-driver-on-windows?forum=netfxbcl
..there is code there that'll go through the registry, find usbser ports, and return their unmangled names. Beware that it doesn't return all serial ports, just ones provided by that driver. The code works on Windows XP through to 10.
The underlying problem is that the usbser.sys driver creates a registry entry, and on .NET (at least up to 3.5) the GetPortNames() function tries to read those registry keys and gets corrupted data. I've reported this to Microsoft, both via that forum (assuming they read it) and using the built-in Windows 10 beta error reporting tool. Maybe one day there will be a fix.
As you say the program works after enabling the windows feature:
.NET 2.0,3.0,3.5 isn't enabled by default on Windows 8/8.1/10. The files aren't stored on the install media/wim.
It can be enabled with the DISM command from windows update or a local source.
DISM /Online /Enable-Feature /FeatureName:NetFx3 /All
check this out: http://forums.radioreference.com/uniden-tech-support/317887-windows-10-uniden-usb-driver-5.html
For a work around to fix the Win 10 serial port not working caused by strange characters after the port name.
Go in to the Registry with regedit.exe.
Navigate to "HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALC OMM"
Make note of the comm port name.
Append a "0" or any character to the comm port name.
Change the comm port name back to what it was in step 3.
It worked for me.
Baldur
string[] ports = SerialPort.GetPortNames();
for (int i = 0; i<ports.Length;i++)
{
string mystr = ports[i];
if (((mystr[mystr.Length-1]) >= 0x30) & ((mystr[mystr.Length-1]) <= 0x39))
{
}
else
{
mystr = mystr.Remove(mystr.Length-1);
}
ports[i] = mystr;
}

Appwarp - Connection Resiliency

I'm currently implementing connection resiliency for a windows phone game following this documentation: Appwarp Connection Resiliency.
I can't seem to access the RecoverConnection API or any of the Connect Event Result Codes related to Connection Resiliency (SUCCESS_RECOVERED, CONNECTION_ERROR_RECOVERABLE, etc) in the ConnectionRequestListener in my project.
Looking at the AppWarp_WP7_SDK.dll in my project it doesnt seem to contain these API calls. I'm using the .dll downloaded from Appwarp Windows SDK. Anyone know has the .dll changed? Have they been removed from the latest version?
Cheers,
xDev
Please take our latest dll from below link
https://github.com/shephertz/AppWarp_WP7_SDK_DLL
We have also one sample game "Catapult War" in which we have implemented Connection Resiliency feature.Find it from below link
https://github.com/rahulpshephertz/CatapultWar
At the time of initialization don't forget to set recovery allowance.
WarpClient.setRecoveryAllowance(60);

Categories

Resources