What is the Binance web socket connection URL? - web3js

var bnbWebSocketUrl = ?;
var web3 = new Web3(new Web3.providers.WebsocketProvider(bnbWebSocketUrl));

It's the URL of your node/provider that support WSS connections.
There is a binance.org HTTP provider mentioned in the docs, but they don't seem to support WSS.
So if you need to use WSS (and not HTTP) connection, you'll probably need to run a node, configure it so that it accepts WSS connections, and connect to this node using WSS. Or you'll need to find a provider that supports this type of connection.
But there's no "one and only / correct" WSS provider as your question suggests.

Related

Jakarta Mail OAUTH support for Office365 over POP protocol

We are trying to connect to Office365 over POP3 using OAUTH. We get the error "Protocol error. Connection is closed. 10" stacktrace mentioned below
javax.mail.AuthenticationFailedException: Protocol error. Connection is closed. 10
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:193)
at javax.mail.Service.connect(Service.java:342)
Below if the snipped of code we are usign to connect
Properties props = new Properties();
props.put("mail.pop3.ssl.enable", "true");
props.put("mail.pop3s.auth.mechanisms","XOAUTH2");
props.put("mail.debug", "true");
session = Session.getInstance(props);
final Store store = session.getStore("pop3s");
store.connect("outlook.office365.com", 995, userId, accessToken);
We are able to connect to Office using IMAP protocol over OAUTH. we tried this with jakarta-mail-1.6.5 and jakarta-mail-1.6.6 both but are unable to resolve the error. Please suggest if we are connecting wrongly or there is any properties missing.
Worked with the workaround mentioned in https://github.com/eclipse-ee4j/mail/issues/461 on Jakarta-mail 1.6.6 development version.

Best way to use database connection for every get/post request in .net core web api service

I have .net core web api service. Should i open new connection and close for every get/post request? Or, is there a performance way to use db connection like a global connection variable?
Yes. You use the AddDbContext extension method to configure your DbContext and it'll automatically create a Scoped instance of the context which is created and disposed with each request:
var connection = #"Server=(localdb)\mssqllocaldb;Database=EFGetStarted.AspNetCore.NewDb;Trusted_Connection=True;ConnectRetryCount=0";
services.AddDbContext<BloggingContext>
(options => options.UseSqlServer(connection));
For a full example visit: https://learn.microsoft.com/en-us/ef/core/get-started/aspnetcore/new-db?tabs=visual-studio

How can I provide a client application (port 443) the ability to consume a REST API (port 9000) on the same server when the port is not public facing?

I am running an angular (1.5+) application on node with express and ui-router, and I would like to connect this application to a REST API that is running on the same server but on a port that is not public facing (9000).
How can I configure my angular application and express server to consume the REST API on port 9000 using server side logic?
An example route and parameter that I would like to hit my REST API on port 9000 would be https://example.com/item/123
Normally i use Express Http Proxy to solve this problem. It is very configurable.
Example code would be:
var proxy = require('express-http-proxy');
// app is your express based Web application in port 443
var app = require('express')();
app.use('/item', proxy('localhost:9000', {
forwardPath: function(req, res) {
return require('url').parse(req.url).path;
}
}));
Using this middleware you can provide custom handling of the request before and after the request to the private API has been performed. Read the documentation for more examples.

Getting javax.mail.MessagingException:Connection reset while trying to connect to MS exchange server using IMAP

I'm trying to connect to Microsoft Exchange server using Javamail. I have used IMAP protocol and port 443 is enabled to listen on exchange server side. I'm getting "javax.mail.MessagingException:Connection reset" error. I'm using javamail 1.4.7 Please help..
Properties prop = new Properties();
prop.setProperty("mail.imap.starttls.enable", "false");
// Use SSL
prop.setProperty("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
prop.setProperty("mail.imap.socketFactory.fallback", "false");
// Use port 443
prop.setProperty("mail.imap.port", "443");
prop.setProperty("mail.imap.socketFactory.port", "443");
prop.setProperty("mail.imaps.class", "com.sun.mail.imap.IMAPSSLStore");
Session session = Session.getDefaultInstance(prop);
Store store = session.getStore("imaps");
store.connect(hostname,username, password);
Port 443 is the https port, not the imaps port.
If you want to use the standard IMAP-over-SSL port, just use the "imaps" protocol and let JavaMail use the default port.
Also, see the JavaMail FAQ for some common mistakes in your code.
Thanks a lot for your suggestions..Yes indeed it was problem with the port. As suggested, I modified my code as below and it works fine now.
Properties prop = new Properties();
//Use SSL
prop.setProperty("mail.smtp.ssl.enable",true);
Session session = Session.getInstance(prop);
Store store = session.getStore("imaps");
store.connect(hostname,username, password);

smtp server to use for sending email through java mail api

I am using java mail api to send email and I need to know the parameters to use for sending a test email in development environment
If I want to use smtp.gmail.com as the smtp mail server , it has port 465 - found on internet , do I need to set authentication to true with username and password also set or authentication=false in fine?
also if authentication=true is required then username, password are my gmail username & password?
Also how to set the cc and bcc addresses in the email message?
Looking for the most basic way to send email to start with
Thanks
If you want to use Gmail, see the JavaMail FAQ.
In order to use gmail as your email server, you have to set a few properties like host,port,authentication etc as per JavaMail API standards. You can get these details from
https://support.google.com/a/answer/176600?hl=en
Sample Code:
public class SendMail
{
public SendMail()
{
// mail properties outgoing server (gmail.com)
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.port", "465");
props.put("mail.smtp.auth", "true");
//Create session object
Authenticator auth = new SMTPAuthenticator();
Session session = Session.getInstance(props,auth);
//prepare mail msg
MimeMessage msg = new MimeMessage(session);
//set header values
msg.setSubject("open to it know it1");
msg.setFrom(new InternetAddress("yyyyyy#gmail.com"));
//Here in below line, you can specify RecipientType as TO/CC/BCC as per your requirement
msg.addRecipient(Message.RecipientType.TO, new InternetAddress("xxxxxxx#gmail.com"));
//msg text
msg.setText("mail from HCL Technlogies");
Transport.send(msg);
private class SMTPAuthenticator extends javax.mail.Authenticator {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("nitraja2015#gmail.com","raryan500");
}
This is not a programming question. Firstly, if you're on not an a dynamically-assigned IP address (that is likely spam-blocked by many mail servers), you don't need an SMTP server. You just take "toaddress#domain" and resolve the "domain" part to a mail exchange handler (DNS MX record lookup) make a direct SMTP connection to that server and put your mail there. You don't program this yourself because mail-handling applications or middleware should know how to do this all by itself.
If you're not on a clean static IP address, you probably can't do that because many SMTP servers will reject connections from such addresses (a common source of spam!).
In that case, your first solution is to relay through the SMTP server provided by your internet provider. (It may be secured, so you have to set up your authentication credentials.)
If that doesn't work (e.g. it is too insecure or otherwise spam-friendly and so widely black-listed) then you look elsewhere for SMTP sending solutions.
Nobody can answer this for you because the best SMTP server depends on how you are hooked up to the Internet.

Resources