JsonServiceClient C# In Excel COM Add-In - json

We develop an Excel COM Add-In using add-in express. We have been using this add-in past 6 months and we don't have any issue. Past few weeks we start facing an issue in the add-in and after debugging I found that we have an issue with the communication channel between add-in and service stack web service. I am not sure quite what has been changed but we are getting error.
The underlying connection was closed: An unexpected error occurred on a send.
I tried to use the same line of codes in the LINQPad, and it works fine. But in the add-in, it does not work and generates the above error.
using (var client = new JsonServiceClient(_config.SchemaServiceUrl))
{
client.UserName = login;
client.Password = password;
response = client.Get<AuthenticateResponse>("/auth");
}
Any suggestions or comments on this?
Regards,
Jamil

Related

Previously working Google Sheets App Script is now throwing the "Failed to establish a database connection" error for MySQL DB

I've been using Google Sheets App Script successfully the past 4 months that is connected to a MySQL 5.7 DB hosted remotely on a VPS (this script connected to my DB successfully earlier today as well). All of a sudden this afternoon my requests are returning "Failed to establish a database connection. Check connection string, username and password." The database connection still works just fine remotely on my computer using MySQL Workbench.
Additional details:
The credentials didn't change (I confirmed with a new connection test)
I have Chrome V8 Runtime disabled since that does not work well at all
I double checked the Google Server IPs to whitelist and noticed 1 server that's either new or I missed the first time, either way all provided IPs are currently whitelisted
I'm connecting using this syntax: var conn = Jdbc.getConnection(url, user, pwd);
I saw some previous comments from a month ago that some people were able to add these parameters successfully: var conn = Jdbc.getConnection(url+'?verifyServerCertificate=false&useSSL=true&requireSSL=true', user, pwd);
However I just get this: Error Invalid argument: _serverSslCertificate
Any further steps or tips to get this connected successfully again is appreciated, thanks!
Austin, you just made my day... Same thing, my MySQL connections stopped working all of a sudden yesterday. Spent hours trying to fix it. The '?useSSL=false' worked like charm.
Thank you, thank you, thank you
I found a solution.
Seems a change on Google now requires you to explicitly set SSL to false. (previously if you let it omitted it would default to off)
?useSSL=false
So you need to update your connection string to something like this simple example.
function myFunction() {
var conn = Jdbc.getConnection("jdbc:mysql://35.214.129.151:3306/dbiyrogncria1r?useSSL=false", "uyxfedtljijfy8", "rnqgnyrs2dthb");
Logger.log(conn);
conn.close();
}
Apparently it's just working again.... must have been a service blip. What's strange is it started working again after I decided to just try var conn = Jdbc.getConnection(url+'?useSSL=false', user, pwd); since I saw some other comments mention that. Seems like an awful solution, but it started working again after I did that, but has continued to work even after I reverted back to just var conn = Jdbc.getConnection(url, user, pwd);
Follow-up questions, are there any good alternatives to Google Sheets with App Script like usage? I'm getting really tired of Google's awful support - would rather pay for a product than to hear "you get what you pay for" with awful support.
EDIT: After this started working again yesterday by itself, the issue came back. I have now confirmed today that switching to var conn = Jdbc.getConnection(url+'?useSSL=false', user, pwd); has solved my connection issue, but that is not an ideal fix by any means at all. Google must be messing with some network settings on the Apps Script side and it's causing issues.

CreateFile failed with 5

I'm using win xp Professional x64 Edition and I'm trying to send message to Windows Message Service like using net send. I'm using mailslot:
LPCTSTR SlotName = TEXT("\\\\.\\mailslot\\messngr");
hFile = CreateFile(SlotName,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
(LPSECURITY_ATTRIBUTES)NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
(HANDLE)NULL);
and after launching it, I got error 5 from GetLastError() in CreateFile. I don't know how to fix it. I gave all VM permission, I turned message service ofc, and I can open it to be notpad like others suggested in: CreateFile() Failed With GetLastError() = 5. I tried many flags, but it didn't change anything. Any guess?
Like it says in the mailslot documentation, only the process that created the mailslot can read from it. Mailslots are one-way communication.
Remove the request for read access.

HTTP Communication failure - 500 Native SSL error

We are using Google API to compute mileage for our travel. Everything was working fine for over 1 year, however we started having the below said issue in the last couple of months.
Our program is able to connect to the API, the API returning with the error message http_communication_failure. The exact error is Application Server
Error 500 Native SSL error
Error is logged with Tag: {0001fee7}Thu Jun
21 09:36:49 2018
When I pasted the URL in the browser, it is returning the mileage information. However through the API call (receive data) in the program, we are getting this error message.
No program changes or Certificate changes have been done in the last 1 year. Our Basis team looked in to the possible issues with SSL. Everything seems to be OK from our end. I looked through your troubleshooting page, and tried all the suggested solutions. Nothing seem to fix our problem. Please let us know what else we need to look at.
CONCATENATE 'https://maps.googleapis.com/maps/api/distancematrix/xml?origins=' lv_dep '&destinations=' lv_arr '&units=imperial'
'&key=' lv_key
INTO lv_http_url.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_http_url
ssl_id = 'ANONYM'
IMPORTING
client = lo_http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
IF sy-subrc EQ 0.
lo_http_client->send( EXCEPTIONS http_communication_failure = 1
http_invalid_state = 2 ).
CALL METHOD lo_http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4.
See if port 443 is create in Trns: smicm, if you can't see it, create it.
increase the trace in menu go to->trace level.
call Appi and see log.
if you see a error about SSL, export the certificate from your PC, I supose is "google trust service".
go trns: STRUST in SAP and inport the new certificate.

C# WebRequest to a URL that is configured for Windows Authentication

I am trying to get user photos out of Microsoft Exchange using the GetUserPhoto REST request documented here: https://msdn.microsoft.com/en-us/library/office/jj190905%28v=exchg.150%29.aspx?f=255&MSPPError=-2147217396
My problem is no matter what I do the connection gets closed automatically and it can't authenticate using NTLM. Microsoft even provides code but when you run this in a IIS web application even if it is using an application pool running as a domain user, it never can authenticate.
This is my current code that isn't working:
request = System.Net.WebRequest.Create($"https://{Settings.ExchangeServer}/ews/exchange.asmx/s/GetUserPhoto?email={primarySmtpAddress}&size=HR240x240") as System.Net.HttpWebRequest;
request.ServerCertificateValidationCallback = delegate { return true; };
request.UseDefaultCredentials = true;
resp = request.GetResponse() as System.Net.HttpWebResponse;
Now I can put this in a console application and run it and then it works. But in IIS it just won't work at all. I've even tried RestSharp with no luck.
Sounds like a delegation issue eg the credentials your impersonating can only be used to access resources local to the IIS server they are being impersonated on. For you to access Exchange you need to have delegation configured correctly see https://blogs.msdn.microsoft.com/emeamsgdev/2012/11/05/ews-from-a-web-application-using-windows-authentication-and-impersonation/
The problem was it wasn't trying to connect with TLS 1.2. Once it clicked in my head, the error message was saying the connection closed and not actually returning a 401. I user ServiceManager to set it to TLS1.2 and then it started working.
Glen Scales help point me in the right direction though to troubleshoot it further.

Silverlight Exceptions on Server [duplicate]

I recently encountered a strange thing. On some of my company's servers when an exception message is printed out (yes, bad, I know. It's for debugging), the actual message isn't displayed. Instead it displays the key for an external string resource and says that "Debugging resource strings are unavailable"
After some research I've come up with the following:
In release mode, Silverlight does not package the xap with the dlls containing the actual error messages in order to save space.
I've found workarounds for OLD versions, but nothing for 4. It seems like there are Developer versions of the SL 2 and 3 runtime which will resolve the errors automatically, but I cannot find one for SL 4.
So my question is this:
What the heck do I need to do to my SL 4 app / computer to let me see the full, detailed errors when it's in release mode?
You can download the developer runtime (which contains the full exception strings) from the GetStarted page - http://www.silverlight.net/getstarted/ - search for "Developer Runtimes for Windows and OSX", it's near the bottom of the page.
Though it is too late to reply, it may help somebody else. We have a web application using Silverlight 4, installed in various test environments. This web application consumes more than one WCF services. All but one of the test environment sites consistently failed with message "Debugging Resource strings are unavailable". Agreeably the real exception was swallowed. Being a Silverlight application, there was no logging, and it always appeared that there was something failing in the Silverlight component. I connected the application in my development environment to that particular test environment, and found out that the problem was in fact in one of the WCF services. I fixed the problem at the service end and the SL component stopped having this problem.
Why was the WCF failing?
The WCF service had the following code in the constructor:
public MyService()
{
//Create an instance of Data Lookup service asycnchronously.
if (_dataLookupSrvc == null)
{
try
{
System.Threading.Tasks.Task.Factory.StartNew(() => _dataLookupSrvc = new LookupDataService.LookupDataService());
}
catch (Exception ex)
{
_log.Error<Exception>(ex);
}
}
}
Somebody moved the underlying LookupDataService.dll from the service folder causing the constructor to fail, but not right away. As the LookupDataService instance was created in anonymous method, the exception logging in this method never took place. Once the LookupDataService.dll was dropped in the service folder, the "Debugging Resource strings are unavailable" message went away.
It was a fun wild goose chase!
Have you already checked the event viewer on the machine where the application crashed? Start->Run. eventvwr