I am working on Monodroid. I have added a Dropnet DLL (I have compiled it in Monodevelop).
I am trying to retrieve account info, below is my code
DropNetClient _client;
string dropbox_appkey = "XXX";
string dropbox_appsecret = "XXXX";
_client = new DropNetClient(dropbox_appkey, dropbox_appsecret);
_client.UserLogin = new DropNet.Models.UserLogin { Token = "XXX", Secret = "XXXX" };
var accountInfo = _client.AccountInfo();
I am getting error when the below code gets executed
return (HttpWebResponse)request.GetResponse();
error received is:
System.Net.WebException: Error getting response stream (Write: The
authentication or decryption has failed.): SendFailure --->
System.IO.IOException: The authentication or decryption has failed.
---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates
(Mono.Security.X509.X509CertificateCollection certificates) [0x00000]
in :0 at
Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1
() [0x00000] in :0 at
Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process ()
[0x00000] in :0 at
Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage
(Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in :0 at
Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback
(IAsyncResult asyncResult) [0x00000] in :0 ---
End of inner exception stack trace --- at
Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback
(IAsyncResult asyncResult) [0x00000] in :0 ---
End of inner exception stack trace --- at
System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult)
[0x00000] in :0 at
System.Net.HttpWebRequest.GetResponse () [0x00000] in :0 at RestSharp.Http.GetRawResponse
(System.Net.HttpWebRequest request) [0x00002] in
e:\sujit\development\try5\restsharp-RestSharp-eef0c86\RestSharp\Http.Sync.cs:170
When I run URL in browser which is something like this:
https://api.dropbox.com/1/account/info?oauth_consumer_key=XXXX&oauth_nonce=3064850&oauth_signature_method=PLAINTEXT&oauth_timestamp=1347899148&oauth_token=XXXX&oauth_version=1.0&oauth_signature=XXX%26XXX
I get proper response like this:
{"referral_link": "https://www.dropbox.com/referrals/XXXX",
"display_name": "XXX XXX", "uid": XXXX, "country": "IN", "quota_info":
{"shared": XXX, "quota": XXXX, "normal": XXXX}, "email":
"XXXX#gmail.com"}
My question is why am I getting strange error using Monodroid Emulator ( I am using Monodevelop version 3.0.4.6 and I am testing on API_10 EMulator.
What should I do?
Note:
Just to add, using Authentication token of dropbox obtained by authenticating it in desktop application. I think we can reuse token of a user which uses our Desktop application for a Mobile application. Right?
I had a similar problem using RestSharp with Mono for Android. The cause was an invalid certificate for the development environment. I was using a static IP address (192.168.1.122) for the domain so that my phone could connect with a web service on my development machine. You can override this by adding the following line somewhere before making the web request:
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
Related
I would like to connect my Orchard CMS v.1.10.1.0 app to an Azure blob storage account. I've followed the same process for years, following this documentation. This process has stopped working for me. My application won't connect to new Azure storage accounts -- be they StorageV1, StorageV2, or Blob Storage.
I can connect to storage accounts that I have used with Orchard in the past--I just can't connect to new storage accounts.
An unhandled exception has occurred and the request was terminated. Please refresh the page. If the error persists, go back
The remote server returned an error: (400) Bad Request.
Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (400) Bad Request. ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) --- End of inner exception stack trace --- at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.Exists(Boolean primaryOnly, BlobRequestOptions requestOptions, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.CreateIfNotExists(BlobContainerPublicAccessType accessType, BlobRequestOptions requestOptions, OperationContext operationContext) at Orchard.Azure.Services.FileSystems.AzureFileSystem.EnsureInitialized() at Orchard.Azure.Services.FileSystems.AzureFileSystem.ListFolders(String path) at Orchard.MediaLibrary.Services.MediaLibraryService.GetMediaFolders(String relativePath) at Orchard.MediaLibrary.Controllers.AdminController.Index(String folderPath, Boolean dialog) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() Request Information RequestID:edaa1946-501e-0035-0d03-9c41ef000000 RequestDate:Tue, 06 Oct 2020 17:10:00 GMT StatusMessage:The TLS version of the connection is not permitted on this storage account.
I solved the issue by putting this line before the call to storage account.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
I was able to solve the issue by going into the Configuration settings for the new storage account and requiring a lower minimum TLS version.
My setup:
Client (http:8080) Nginx (FastCGI:9000) fastcgi-mono-server
I want to host ASP.NET MVC 4 application, entirely built with WebAPI 2 controllers, configuration, etc, on Ubuntu with Mono 4 and fastcgi-mono-server4, but for WebAPI routes it returns 400:
System.ArgumentNullException
Value cannot be null.
Parameter name: path
Description: HTTP 400.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at System.IO.DirectoryInfo.CheckPath (System.String path) [0x00006] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at System.IO.DirectoryInfo..ctor (System.String path, System.Boolean simpleOriginalPath) [0x00006] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <dca3b561b8ad4f9fb10141d81b39ff45>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:.ctor (string)
at Mono.WebServer.FastCgi.WorkerRequest.GetFilePath () [0x00035] in <a872d12009ac4a668f0d504d764f1c44>:0
at Mono.WebServer.MonoWorkerRequest.GetFilePathTranslated () [0x00001] in <5b4128956e344d60b82a5fd7012fd8a1>:0
at Mono.WebServer.MonoWorkerRequest.AssertFileAccessible () [0x00010] in <5b4128956e344d60b82a5fd7012fd8a1>:0
at Mono.WebServer.MonoWorkerRequest.ProcessRequest () [0x0000b] in <5b4128956e344d60b82a5fd7012fd8a1>:0
On my development machine runs fine both via xsp4 and via MonoDevelop "run" button. Haven't tried fastcgi-mono-server4, but if you think it's relevant I will.
As I said above behavior only occurs for urls matching WebAPI routes - e.g. /api/products, which means configuration works and I suppose it has something to do with the environment.
I have started fastcgi-mono-server as follows: MONO_OPTIONS=--trace=E:System.Exception fastcgi-mono-server4 /appconfigdir=/etc/mono/fastcgi /socket=tcp:127.0.0.1:9000 and when hitting WebAPI urls it outputs this:
[0x7f8276459700:] EXCEPTION handling: System.ArgumentNullException: Value cannot be null.
Parameter name: path
My code does not do any IO, only database (but we're not quite there yet). As I said above behavior only occurs for urls matching WebAPI routes - e.g. /api/products, which means configuration works and I suppose it has something to do with the environment.
This is happening because a required parameter is missing.
I encountered this today. I found that in /etc/nginx/fastcgi_params, I needed to add the following line:
fastcgi_param PATH_INFO "";
And in the server configuration, I needed to import this file:
server {
listen 80;
...
location / {
...
fastcgi_pass 127.0.0.1:9000;
include /etc/nginx/fastcgi_params;
}
}
Of course you might be missing a different parameter.
I have an iOS application that developed by Xamarin Studio.
When I try to get a string from server I got the following exception.
Exception in Class: WebClient
Line : 271
and Method:DownloadDataCore
with message Error: SendFailure (Error writing headers)
Stack Trace: at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:971
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/HttpWebRequest.cs:985
at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:1563
at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:972
at System.Net.WebClient.DownloadDataCore (System.Uri address, System.Object userToken) [0x0000a] in ///Library/Frameworks/Xamarin.iOS.framework/Versions/8.2.0.207/src/mono/mcs/class/System/System.Net/WebClient.cs:271
When I try to download the string from a none-SSL website it is ok and loads the string without any problem.
The website certificate is completely valid and It doesn't refused by Safari both in simulator and OSX.
I am runing the application on simulator.
I will be so thankful if you can help me fix the issue.
The code that I used for getting string from server is :
System.Net.ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
WebClient wc = new WebClient ();
wc.CachePolicy = new System.Net.Cache.RequestCachePolicy (System.Net.Cache.RequestCacheLevel.NoCacheNoStore );
result = wc.DownloadString (Url);
Regards
Before accessing SSL site with mono, you have to run mozroots --import --sync to import list of mozilla trusted certificates.
Also, there is mono security FAQ which can help to resolve SSL issues.
We just deployed a new v6 site to a host that has several v4 sites running on it no problem. On the front end, it looks fine, but in the Umbraco admin the Content and Media trees appear empty.
In the browser debugger I can see that there is an error in the TreeDataService.ashx.
The error is below and I'm not exactly sure what the issue is. Is it permissions? Database user permissions?
----------
You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: You must set the singleton 'Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig' to use an sql syntax provider
Parameter name: SqlSyntaxProvider]
Umbraco.Core.Persistence.SqlSyntax.SyntaxConfig.get_SqlSyntaxProvider() +89
Umbraco.Core.Persistence.Mappers.BaseMapper.GetColumnName(Type dtoType, PropertyInfo dtoProperty) +57
Umbraco.Core.Persistence.Mappers.ContentMapper.Map(String propertyName) +67
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitMemberAccess(MemberExpression m) +112
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +101
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitBinary(BinaryExpression b) +258
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +159
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.VisitLambda(LambdaExpression lambda) +120
Umbraco.Core.Persistence.Querying.ModelToSqlExpressionHelper`1.Visit(Expression exp) +72
Umbraco.Core.Persistence.Querying.Query`1.Where(Expression`1 predicate) +20
Umbraco.Core.Services.ContentService.GetChildren(Int32 id) +312
umbraco.cms.businesslogic.web.Document.GetChildrenForTree(Int32 NodeId) +39
umbraco.cms.presentation.Trees.BaseContentTree.Render(XmlTree& Tree) +27
umbraco.loadContent.Render(XmlTree& tree) +19
umbraco.presentation.webservices.TreeDataService.LoadTree(TreeRequestParams treeParams) +79
umbraco.presentation.webservices.TreeDataService.GetXmlTree() +140
umbraco.presentation.webservices.TreeDataService.ProcessRequest(HttpContext context) +55
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
check you umbraco db connection string.
<add name="umbracoDbDSN".......
if it do contains
providerName="System.Data.SqlClient"
then Add it and check. the same. it might start working.
Problem is that SqlSyntaxProvider is null, my workaround is init it.
var service = new Umbraco.Core.Services.ContentService();
SqlSyntaxContext.SqlSyntaxProvider = new MySqlSyntaxProvider();
The connection string, add name="umbracoDbDSN" ... was missing the following providerName="System.Data.SqlClient"
Once I added that to the line things started working.
I am trying to send an XML via web client on Monotouch. Although everything is working on the iOS simulator I get an exception when the app is running on the device. Here is the code.
try
{
Byte[] sendData = System.Text.Encoding.UTF8.GetBytes(someXML) ;
WebClient client = new WebClient();
Byte[] forResp;
client.Headers.Add("Content-Type","text/xml");
bresp = wc.UploadData(URL, sendData);
string resp = System.Text.Encoding.ASCII.GetString(forResp);
XmlDocument xresp = new XmlDocument();
xresp.LoadXml(resp);
return xresp;
}
catch
{
// error
}
I tried the WebClient because I had the same issue with the HttpWebRequest.
Exception:
The request timed out
System.Net.WebException: The request timed out
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00065] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:830
at System.Net.HttpWebRequest.GetResponse () [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:836
at System.Net.WebClient.GetWebResponse (System.Net.WebRequest request) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:1433
at System.Net.WebClient.ReadAll (System.Net.WebRequest request, System.Object userToken) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:866
at System.Net.WebClient.UploadDataCore (System.Uri address, System.String method, System.Byte[] data, System.Object userToken) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:462
at System.Net.WebClient.UploadData (System.Uri address, System.String method, System.Byte[] data) [0x00035] in /Developer/MonoTouch/Source/mono/mcs/class/System/System.Net/WebClient.cs:441
The stacktrace tells us that the timeout occurs when WebClient tries to get a response from the server (and not when uploading the data to the server). That means access to the server is not the issue (and why stacktraces are very useful ;-)
The next steps depends if you have control, or not, of the server. If you control the server then check it's logs to find the request and see how it was handled. If possible also ensure you received/decoded the data identically between the simulator and device.
If you do not control the server then it's harder to know what's going on inside it. E.g. maybe it did not like the request (i.e. the server code can decide not to answer based on any condition, including the user-agent).
In such case using a tool, like wireshark, is often your best bet. Compare the session from the iOS simulator and from the device.
Is the request identical ? e.g. the data you uploaded could be different due to something else;
Is the server answering for the device ? with the same status code ? in the same time frame ?
If everything is identical then you might have found a bug. Please report it (along with the above informations and files) to http://bugzilla.xamarin.com
Otherwise you should have more precise clues to debug the issue and/or update the question to be more specific :-)