websocketpp: Getting exception on tls init handler - websocket

I am nusing WebSocket++/0.3.0-alpha4 in my wxwidgets application (win32).
So far, I am able to connect the ws url ( ws://localhost:3000).
But getting prb while trying with the wss url (wss://localhost:443).
I have created a object of client as follows.
typedef websocketpp::clientwebsocketpp::config::asio_tls_client client;
client m_client;
and register the tls handler on constructor as follows,
m_client.set_tls_init_handler(bind(&WebSocketClient::on_tls_init, this,::_1));
When call comes in this handler, it throws an exception on very first line written as follows
context_ptr ctx(new boost::asio::ssl::context(boost::asio::ssl::context::tlsv1));
While debugging, I came to know is exception is thrown from context.ipp ( Boost\asio\ssl\impl)..
if (handle_ == 0)
{
boost::system::error_code ec(
static_cast(::ERR_get_error()),
boost::asio::error::get_ssl_category());
boost::asio::detail::throw_error(ec, "context");
}
What's going wrong here. Please Help.

Related

Getting an err status 500 connecting reactmongo to mlabs

SOLUTION in the bottom
i'm trying to connect my reactive spring webflux project to mongodb via mlabs. But from the api and documentation i don't know which method is causing my problem. I set up two methods to work with my mlab db but don't know which should I stick to.
Method 1 > in the application properties set up my mlab uri
spring.data.mongodb.uri=mongodb://<fernando>:<password>#ds261277.mlab.com:61277/cont-api?AuthMechanism=SCRAM-SHA-1
i've tried lower case, with & ampersand instead of question mark and adding
spring.data.mongodb.database=mycollection
Result: My code runs but when i make any request(get, post, etc) i get an error, adding or removing the "?AuthMechanism=SCRAM-SHA-1" doesn't make a difference
ERROR 2423 --- [ntLoopGroup-2-2] a.w.r.e.AbstractErrorWebExceptionHandler : [eb675923] 500 Server Error for HTTP POST "/content/v1/cont/"
org.springframework.data.mongodb.UncategorizedMongoDbException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='<fernando>', source='cont-api', password=<hidden>, mechanismProperties={}}; nested exception is com.mongodb.MongoSecurityException: Exception authenticating MongoCredential{mechanism=SCRAM-SHA-1, userName='<fernando>', source='cont-api', password=<hidden>, mechanismProperties={}}
Method 2 > create a dataConfig like so, but when i run, i get an error of trying to connect to local mongodb
#Configuration
public class DataConfig {
private static final String DATABASE_NAME = "hospitals";
private static final String DATABA_URL = "mongodb://<fernando>:<password>#ds261277.mlab.com:61277/cont-api";
MongoClient mongoClient = MongoClients.create(new ConnectionString(DATABA_URL));
MongoDatabase database = mongoClient.getDatabase(DATABASE_NAME);
// #Bean
// public ReactiveMongoDatabaseFactory mongoDatabaseFactory(MongoClient mongoClient){
// return new SimpleReactiveMongoDatabaseFactory(mongoClient, DATABASE_NAME);
// }
//
// #Bean
// public ReactiveMongoOperations reactiveMongoTemplate(ReactiveMongoDatabaseFactory database){
// return new ReactiveMongoTemplate(database);
// }
}
Results:
[localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
any help would be great, thanks in advance
UPDATE & SOLUTION :
So i scrapped method two and stuck to method one, i just had to remove the angle brackets from the mlab uri so instead of it's now //fernando:password ...
So heads up to anyone using mlab, completely forgot to remove the angle brackets < >
Before:
spring.data.mongodb.uri=mongodb://<fernando>:<password>#ds261277.mlab.com:61277/cont-api
After: without < > around the user and password
spring.data.mongodb.uri=mongodb://fernando:password#ds261277.mlab.com:61277/cont-api

SseEmitter MessageBodyWriter not found for media type=text/event-stream

I am trying to get server-sent events working with a JavaScript web client and a Spring Boot 1.5.7 application. I get the following error in the server log when the SseEmitter is returned from the REST endpoint when the client initially connects:
o.g.j.m.i.WriterInterceptorExecutor :
MessageBodyWriter not found for media type=text/event-stream,
type=class org.springframework.web.servlet.mvc.method.annotation.SseEmitter,
genericType=class org.springframework.web.servlet.mvc.method.annotation.SseEmitter
The REST method gets called fine and I create and save the emitter for later. When the emitter is returned from the REST method, the above exception gets thrown.
I only get this when using EventSource in the web clients (Chrome and Firefox), not when using curl. I can even enter the URL in the browser and get a response without getting an error on the server.
I'm following pretty much every example I could find.
JavaScript:
const es = new EventSource('https://localhost:8443/sse');
es.onmessage = e => {console.log(e.data);};
es.onerror = e => {console.log('onerror:' + e);};
es.onopen = e => {console.log('onopen');};
Server:
#GET
#Path("/sse")
#Produces({"text/event-stream"})
public SseEmitter sse() {
SseEmitter emitter = new SseEmitter();
... save for later ...
return emitter;
}
Any ideas?
Thank You.

quickbooks online sdk v3 how to troubleshot a badrequest/ValidationException

When debugging a program using the QuickBooks Online API V3 with the SDK. How do you troubleshoot a bad request coming from DataServices. I have gone through several layers of the Exception innerExceptions and I only see ValidationException.
But what tripped the validation exception???
Is there a log to see what caused the problem?
catch (Intuit.Ipp.Exception.IdsException ex)
{
//TODO: handle dupe or other....
var returnMessage = string.Empty;
var innerException = ((Intuit.Ipp.Exception.ValidationException)(ex.InnerException)).InnerExceptions.FirstOrDefault();
if (innerException != null)
{
returnMessage = innerException.Message;
}
}
I just found out this when looking deeply into the exception generated.
Generally speaking you will get an exception and you check if the inner exception object is not null or nothing, if it has an inner exception you look at it.
You will notice that every exception also has a property called "InnerExceptions" (plural) which is a list containing inner exceptions, this property will be null when you have a proper inner exception, but in the last one (in my case) when the inner exception property is null this list contains one inner exception with the details.
This property is available on Intuit.Ipp.Exception.IdsException and contain a list of IdsError
I'm using the IPP .Net SDK 3.0 API (version 2.0.2.0)
For .Net SDK please enable request/response logs. Th details for bad exception get saved in these files.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging
Please mention which SDK(JAVA/.NET/PHP) you are using.
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits
You can set the logger to debug mode to capture the raw request and response XMLs. From the response XML, you'll get the details of failure(if any).
Otherwise, you can call these endpoints directly from APIExplorer.
https://developer.intuit.com/apiexplorer?apiname=V3QBO
Thanks
Simply collect the Error Message coming from Quickbook API. Make following the first catch block statement:
catch (Intuit.Ipp.Exception.IdsException ex)
{
string errorMessage = (((Intuit.Ipp.Exception.ValidationException)(ex.InnerException)).InnerExceptions.FirstOrDefault() ?? new Exception()).Message;
// you can further log the error .
}

BreezeJS - server validation changed in version 1.4.4

I've updated breezejs from version 1.4.1 to 1.4.4. For server-side validation, I was handling the AfterSaveEntitiesDelegate on the ContextProvider and throwing EntityErrorsException().
In the release notes I read:
The Breeze WebApi response to any SaveChanges operation that has
validation errors now returns a 403 status code, instead of a 200.
This has no effect on any Breeze code but will be noticeable to anyone
watching Breeze's network traffic.
However, the new 403 error does not have any details about the validation error or any inner exceptions that would indicate it is a validation error. Instead the error is: "Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details." There is no "Response" property. Also, now my client-side code no longer "understands" this error.
Turns out that this exception is not intended to be caught and wrapped into an HttpResponseMessage. My code for the BreezeController SaveChanges() api was:
try
{
return Request.CreateResponse(HttpStatusCode.OK, _commDataService.SaveChanges(pSaveData, shouldValidate));
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex);
}
This was returning the right exception but with the wrong status code (500 instead of 403 as expected by updated breezejs client code.
I added a new catch to pass along the breeze-constructed response message:
catch (System.Web.Http.HttpResponseException responseException)
{
//todo: logger call.
return responseException.Response;
}

Failed to connect to an IPC Port: The system cannot find the file specified

In my .net 2.0 application Remote object suddenly destroyed and thrown the below exception.
"Failed to connect to an IPC Port: The system cannot find the file specified."
I have IPC remoting server and which create a singleton object.
i have override the InitializeLifetimeService() method and returns null for infinite lifetime.
server and client applications are working fine but some times we got the above exception.
serverCode:
//create and register the processheartbeat.
BinaryServerFormatterSinkProvider serverprovider = new BinaryServerFormatterSinkProvider();
serverprovider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
//Hosts the Heartbeat object and registers it.
processHeartbeatChn = new IpcServerChannel("HeartbeatChannel", "localhost:" + applicationHeartbeatPort, serverprovider);
//registers the channel
ChannelServices.RegisterChannel(processHeartbeatChn, false);
//register the service
RemotingConfiguration.RegisterWellKnownServiceType(typeof(Heartbeat),
appName, WellKnownObjectMode.Singleton);
ClientCode:
string uri = string.Format(CultureInfo.InvariantCulture,"ipc://localhost:{0}/{1}", applicationHeartbeatPort, appName);
//get the Heartbeat object
remoteHeartbeat = (Heartbeat)Activator.GetObject(typeof(Heartbeat), uri);
any hot fix is there to resolve this problem?
can any one help me an this?

Resources