I'm trying to produce to kafka using c# and confluent.
This code works just fine when I'm connected To Internet:
ProducerConfig _config = new ProducerConfig();
_config.BootstrapServers = "127.0.0.1:9092";
using (var producer = new ProducerBuilder<Null, string>(_config).Build())
{
await producer.ProduceAsync("NewTopic", new Message<Null, string> { Value = "NewTopic" });
producer.Flush(TimeSpan.FromSeconds(10));
Console.WriteLine("Message Send!");
Console.ReadLine();
}
But When I'm Offline I Get This Error: %3|1639785660.784|FAIL|rdkafka#producer-1| [thrd:localhost:9092/0]: localhost:9092/0: Failed to resolve 'localhost:9092': The requested name is valid, but no data of the requested type was found. (after 4ms in state CONNECT)
Does Anyone Knows Why?
Related
We are using Renci.SshNet C# library to connect to SFTP server.
Today connection on code line
client.Connect();
to server stopped working with error message:
Unhandled Exception: Renci.SshNet.Common.SshConnectionException: The
connection was closed by the server: Your cipher needs to be updated:
https://developer.eba
y.com/devzone/merchant-products/mipng/user-guide-en/default.html#advanced-featur
es.html . please contact MIP Support for help (ByApplication). at
Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan
timeout)
I installed latest SSH.NET and .NET Framework, and still same error
Could anyone help what needs to be done to fix that error?
Appreciate any help
I encountered the same issue. Here is the fix for SSH.NET client w/ C#
var connectionInfo = new ConnectionInfo(...);
var deprecatedMacs = new List<string>
{
"hmac-md5",
"hmac-md5-96",
"hmac-md5-etm#openssh.com",
"hmac-sha1-96",
"hmac-sha2-256-96",
"hmac-sha2-512-96"
};
var deprecatedCiphers = new List<string>
{
"aes128-cbc",
"aes192-cbc",
"aes256-cbc",
"blowfish-cbc",
"3des-cbc",
"3des-ctr",
"arcfour",
"arcfour128",
"arcfour256"
};
// remove deprecated macs
foreach(var deprecatedMac in deprecatedMacs)
{
connectionInfo.HmacAlgorithms.Remove(deprecatedMac);
}
// remove deprecated ciphers
foreach(var deprecatedCipher in deprecatedCiphers)
{
connectionInfo.Encryptions.Remove(deprecatedCipher);
}
using (var client = new SftpClient(connectionInfo))
{
try
{
client.Connect(); // Should work now
}
catch (Exception ex)
{
// ...
}
}
when I try to create a hotspot connection in my Xamarin.IOS project I get the following error returned in the description when using NEHotspotConfigurationManager :
Error Domain=NEHotspotConfigurationErrorDomain Code=8 \"internal error.\" UserInfo={NSLocalizedDescription=internal error.}
I have tried to connect to both the network in the office and my phone's wifi hotspot and both return the same message. I have enabled both the options "Accept WiFi Information" and "Hotspot" on both the App ID on the developer portal and also the same in the Entitlements.plist and still the same error. I'm using the code shown below.
public async void JoinNetwork()
{
NEHotspotConfiguration config = new NEHotspotConfiguration("CTIP");
config.JoinOnce = false;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err => tcs.SetResult(err));
var error = await tcs.Task;
if (error != null)
{
PAGE.IOSErrorAlert(error.Description, this);
return;
}
}
Try you code as below
NEHotspotConfiguration config = new NEHotspotConfiguration("CTIP" ,passphrase , false);
config.JoinOnce = true;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err =>
tcs.SetResult(err));
and try to restart your device ,this seems like a known issue on apple side .
Refer to
https://stackoverflow.com/a/47769497/8187800
https://developer.apple.com/forums/thread/107851
I'm working on a Xamarin application where i'm establishing a connection with a Server. The server code is currently a blackbox for me, i only have the documentation.
However, since the server switched to TLS1.2 i'm trying use .NET's SslStream to authenticate on my app. I made sure that both are using the same certificate. The certificate is selfsigned though.
Whenever i try to do AuthenticateAsClient i get the following exception:
Mono.Security.Interface.TlsException: Unknown Secure Transport error `PeerHandshakeFail'.
Here's some part of my code:
using (var stream = new SslStream(new NetworkStream(mainSocket), false, new RemoteCertificateValidationCallback(ValidateServerCertificate)))
{
try
{
stream.AuthenticateAsClient(ServerIpAdressServer, GetX509CertificateCollection(), System.Security.Authentication.SslProtocols.Tls12, false);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
(The ValidateServerCertificate always returns true)
Here's my method to get the certificate:
public static X509CertificateCollection GetX509CertificateCollection()
{
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MyClass)).Assembly;
X509CertificateCollection collection1;
using (MemoryStream ms = new MemoryStream())
{
assembly.GetManifestResourceStream("namespace.cert.pem").CopyTo(ms);
X509Certificate2 certificate1 = new X509Certificate2(ms.ToArray());
collection1 = new X509CertificateCollection();
collection1.Add(certificate1);
}
return collection1;
}
Thanks in advance!
Here is a Warning in document about TLS1.2 in Xamarin IOS.May be helpful for you.
the downside is that it requires the event loop to be running for async operations to be executed.
SslStream.AuthenticateAsClientAsync Method : Authenticate the client side of a client-server connection as an asynchronous operation.
So from your testing with async method ,this is the right solution. Glad solved it.
I am trying out Couchbase database, I've followed the tutorial here:
http://developer.couchbase.com/documentation/server/4.0/sdks/dotnet-2.2/hello-couchbase.html
I've installed the nugget from Package manager, and started to code. But as I am trying to call Cluster.OpenBucket function I am getting :
An unhandled exception of type 'System.AggregateException' occurred in Couchbase.NetClient.dll
"A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection
failed because connected host has failed to respond"
That's my code:
class DbMgr
{
private static readonly Cluster Cluster = new Cluster();
const string BUCKET_NAME = "This-Is-A-Bucket-Name";
public void Init()
{
//This is where I get exception....
using (var bucket = Cluster.OpenBucket(BUCKET_NAME, ""))
{
var document = new Document<dynamic>
{
Id = "Hello",
Content = new
{
name = "Couchbase"
}
};
}
}
}
Any Ideas?
For implementing my websocket server in C# I'm using Alchemy framework. I'm stuck with this issue. In the method OnReceive when I try to deserialize json object, I get a FormatException:
"Incorrect format of the input string." (maybe it's different in english, but I'm getting a localized exception message and that's my translation :P). What is odd about this is that when I print out the context.DataFrame I get: 111872281.1341000479.1335108793.1335108793.1335108793.1; __ad which is a substring of the cookies sent by the browser: __gutp=entrystamp%3D1288455757%7Csid%3D65a51a83cbf86945d0fd994e15eb94f9%7Cstamp%3D1288456520%7Contime%3D155; __utma=111872281.1341000479.1335108793.1335108793.1335108793.1; __adtaily_ui=cupIiq90q9.
JS code:
// I'm really not doing anything more than this
var ws = new WebSocket("ws://localhost:8080");
C# code:
static void Main(string[] args) {
int port = 8080;
WebSocketServer wsServer = new WebSocketServer(port, IPAddress.Any) {
OnReceive = OnReceive,
OnSend = OnSend,
OnConnect = OnConnect,
OnConnected = OnConnected,
OnDisconnect = OnDisconnect,
TimeOut = new TimeSpan(0, 5, 0)
};
wsServer.Start();
Console.WriteLine("Server started listening on port: " + port + "...");
string command = string.Empty;
while (command != "exit") {
command = Console.ReadLine();
}
Console.WriteLine("Server stopped listening on port: " + port + "...");
wsServer.Stop();
Console.WriteLine("Server exits...");
}
public static void OnReceive(UserContext context) {
string json = "";
dynamic obj;
try {
json = context.DataFrame.ToString();
Console.WriteLine(json);
obj = JsonConvert.DeserializeObject(json);
} catch (Exception e) {
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
return;
}
}
On the C# side I'm using Newtonsoft.Json, though it's not a problem with this library...
EDIT:
One more thing - I browsed through the code in here: https://github.com/Olivine-Labs/Alchemy-Websockets-Example and found nothing - I mean, I'm doing everything the same way authors did in this tutorial...
EDIT:
I was testing the above code in Firefox v 17.0.1, and it didn't work, so I tested it under google chrome, and it works. So let me rephrase the question - what changes can be made in js, so that firefox would not send aforementioned string?
I ran into the same issue - simply replacing
var ws = new WebSocket("ws://localhost:8080");
with
var ws = new WebSocket("ws://127.0.0.1:8080");
fixed the issue for me.
In C# console app I connect the client to the server using :
var aClient = new WebSocketClient(#"ws://127.0.0.1:81/beef");
Your code above is connecting using
var ws = new WebSocket("ws://localhost:8080");
There could be one of two issues -
First is to see if WebSocketClient works instead.
To make sure your url is of the format ws://ur:port/context. This threw me off for a while.