I tried enabling stream management(XEP-0198) by this piece of code
XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
.setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
.setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();
XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);
connection.setPacketReplyTimeout(TIME_OUT);
connection.connect();
connection.login();
connection.setUseStreamManagement(true);
But later when I check for stream management it returns false.
I guess you need to set stream management before connecting to xmpp.
XMPPTCPConnectionConfiguration connConfig = XMPPTCPConnectionConfiguration.builder().setHost(HOST)
.setPort(PORT).setDebuggerEnabled(true).setSecurityMode(SecurityMode.disabled)
.setUsernameAndPassword(USERNAME, PASSWORD).setServiceName(SERVICE).build();
XMPPTCPConnectionconnection = new XMPPTCPConnection(connConfig);
connection.setUseStreamManagement(true);
connection.setPacketReplyTimeout(TIME_OUT);
connection.connect();
connection.login();
Related
How to call HTTPS WCF web service in Plugin, plugin assembly is registered in sandbox mode. I am getting System.Security.SecurityException exception, Can somebody please provide the way to all https web service. My code is below :
BasicHttpBinding myBinding = new BasicHttpBinding();
myBinding.MaxReceivedMessageSize = Int32.MaxValue;
myBinding.Name = “basicHttpBinding”;
if (EndPoint.ToLower().Contains(“https://”))
{
//Throwing exception here – System.Security.SecurityException exception,
ServicePointManager.ServerCertificateValidationCallback += (sendr, cert, chain, sslPolicyErrors) => true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768 | (SecurityProtocolType)3072 | (SecurityProtocolType)192;
myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
}
else
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
myBinding.Security.Mode = BasicHttpSecurityMode.None;
}
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
myBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
myBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
EndpointAddress endPointAddress = new EndpointAddress(EndPoint);
WebIALClient myClient = new WebIALClient(myBinding, endPointAddress)
Since you are in on-premise version, you can register the plugin assembly in non-sandbox mode. ie Isolation mode = none to overcome such errors.
In case you wanted to use sandbox mode, try using WebClient class for invoking WCF service call. Read more
using (WebClient client = new WebClient())
{
byte[] responseBytes = client.DownloadData(webAddress);
string response = Encoding.UTF8.GetString(responseBytes);
tracingService.Trace(response);
// For demonstration purposes, throw an exception so that the response
// is shown in the trace dialog of the Microsoft Dynamics CRM user interface.
throw new InvalidPluginExecutionException("WebClientPlugin completed successfully.");
}
Can you try and also include: using System.Web.Http.Cors;
[EnableCors(origins: "*", headers: "*", methods: "*")]
[Route("api/ConvertUpload/{env}/{id}")]
public string Get(string env, string id)
{
return "hi";
}
You may have to use WebClient as #Arun has mentioned.
I was trying to follow the ktor documentation for Raw Sockets and in specific the part related to secured sockets (https://ktor.io/servers/raw-sockets.html):
runBlocking {
val socket = aSocket(ActorSelectorManager(ioCoroutineDispatcher)).tcp().connect(InetSocketAddress("google.com", 443)).tls()
val w = socket.openWriteChannel(autoFlush = false)
w.write("GET / HTTP/1.1\r\n")
w.write("Host: google.com\r\n")
w.write("\r\n")
w.flush()
val r = socket.openReadChannel()
println(r.readUTF8Line())
}
You can adjust a few optional parameters for the TLS connection:
suspend fun Socket.tls(
trustManager: X509TrustManager? = null,
randomAlgorithm: String = "NativePRNGNonBlocking",
serverName: String? = null,
coroutineContext: CoroutineContext = ioCoroutineDispatcher
): Socket
But the NativePRNGNonBlocking SecureRandom algorithm is not available on Windows, so my only option was to use SHA1PRNG (https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html#SecureRandomImp)
This is the code I'm running to connect to a listening socket :
socket = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().connect(InetSocketAddress(host, port))
.tls(Dispatchers.IO, randomAlgorithm = "SHA1PRNG")
Unfortunately, I always receive the same error: "Channel was closed"
If I remove tls, keeping only the raw socket:
socket = aSocket(ActorSelectorManager(Dispatchers.IO)).tcp().connect(InetSocketAddress(host, port))
Everything works as expected.
Does anyone has used Ktor Secure Sockets in Windows ? (Unfortunately, Ktor's documentation still has a long way to go).
Thanks,
J
XMPPTCPConnectionConfiguration conf = XMPPTCPConnectionConfiguration.builder()
.setXmppDomain("404.city").setUsernameAndPassword("user", "password")
.setCompressionEnabled(false)
.setSecurityMode(ConnectionConfiguration.SecurityMode.required)
.setCustomSSLContext(sslcont)
.build();
XMPPTCPConnection connection = new XMPPTCPConnection(conf);
if(connection.isConnected()){
System.out.println("already connected");
return;
}
connection.connect();
connection.login();
I am new to smack, I am trying to use smack 4.2.1 to connect the xmppserver(openfire).The code is login with a username and password,but when I try to modify the code.There is no loginAnonymous function.
How Can I Login as a anonymous?Please guide me
There are two functions allowEmptyOrNullUsernames() and performSasAnonymousAuthentication().When set the configuration of XMPPTCPConnection ,it can be called.
I am trying to create a MultiUser Chat room using Java..
This is my code...
ConnectionConfiguration config = new ConnectionConfiguration("ip_address", 5222, "admin.com");
config.setSecurityMode(SecurityMode.disabled);
XMPPTCPConnection connection = new XMPPTCPConnection(config);
connection.connect();
connection.login(username, password);
MultiUserChat mucRoom = new MultiUserChat(connection, groupId#hostname);
mucRoom.create("unio_groups_" + groupId);
However, I am getting an excepton "org.jivesoftware.smack.SmackException$NoResponseException"..
I am trying to send mail using SmtpClient and below is my code.
SmtpClient client_ = new SmtpClient("relay-hosting.secureserver.net", 25);
//client_.DeliveryMethod = SmtpDeliveryMethod.Network;
//client_.EnableSsl = true;
// client_.UseDefaultCredentials = false;
//client_.Credentials = new System.Net.NetworkCredential(_fromAddress, _password);
MailAddress from_ = new MailAddress(_fromAddress, _fromName);
MailMessage msg_ = new MailMessage(from_, from_);
msg_.Subject = "Subject";
StringBuilder body_ = new StringBuilder();
body_.AppendLine("Line1");
body_.AppendLine("===============================================================================================");
body_.AppendLine("Line2");
body_.AppendLine("===============================================================================================");
body_.AppendLine("line2");
body_.AppendLine("===============================================================================================");
msg_.Body = body_.ToString();
msg_.IsBodyHtml = true;
client_.Send(msg_);
I am getting TimeOut error. When Same smtp configuration using in email client on my machine, it send the mail immediately. I don't know what can be cause. Also when I used my Gmail account with gmail smpt server it worked.
Most consumer ISPs block port 25 to prevent you from running a mail server.
Therefore, you cannot connect to port 25 from your house.
You can ask them for an alternate port.
Try port 587; it's commonly used as well.