Domain=NSURLErrorDomain Code=-1005 "The network connection was lost in swift5 - alamofire

I am using swift5 & Xcode Version 13.0 (13A233). I am using cocapod
pod 'Alamofire' , '~> 4.9.1'
I just connect using IP, it is working fine.But when I connect to domain like https://www.example.net it shows
Error Domain=NSURLErrorDomain Code=-1005 "The network connection was lost." UserInfo={_kCFStreamErrorCodeKey=-4, NSUnderlyingError=0x600002af2b50 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x6000007c8230 [0x1056ddaf0]>{length = 16, capacity = 16, bytes = 0x100201bb772858170000000000000000}, _kCFStreamErrorCodeKey=-4, _kCFStreamErrorDomainKey=4}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <A49E8D5B-1DE3-487C-B4F7-50376AF188AE>.<3>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <A49E8D5B-1DE3-487C-B4F7-50376AF188AE>.<3>"
), NSLocalizedDescription=The network connection was lost., NSErrorFailingURLStringKey=https://www.example.net/api/second-api, NSErrorFailingURLKey=https://www.example.net/api/second-api, _kCFStreamErrorDomainKey=4}
I have also add App Transport Security Settings like bellow & here is the image
Here is the code I have used..
API One:
func firstApi() {
Alamofire.request("https://www.example.net/api/first-api", method: .post, parameters: [
"param1":"",
"param2":"",
],headers: headers).responseJSON{ [self](responseData) -> Void in
secondApi()
}
}
API Two:
func secondApi() {
Alamofire.request("https://www.example.net/api/second-api", method: .post, parameters: [
"param1":"",
"param2":"",
"param3":"",
],headers: headers).responseJSON{ [self](responseData) -> Void in
}
}
In the above code, I have called Second API from first API. First API is responding nicely. But in second API which I call from first API response shows above error..
But Only single API called but when I call another API from single API shows error
I don't know what is reason. Please help me to solve the problem..

Related

WebRTC Error - Session error description: Data channel type mismatch. Expected RTP, got SCTP

I am new to WebRTC and triyng to create my first app. I have found this article https://www.tutorialspoint.com/webrtc/webrtc_quick_guide.htm and did as it was said there. The resulted app works fine if I test it in the Chrome. But when I try to test this app in 2 browser (Chrome and Mozilla) it gives me this error:
Uncaught (in promise) DOMException: Failed to execute
'setRemoteDescription' on 'RTCPeerConnection': Session error code:
ERROR_CONTENT. Session error description: Data channel type mismatch.
Expected RTP, got SCTP..
This happens when I send an offer from Mozilla client and Chrome client tries to give an answer to this offer in this part of code:
myConnection.setRemoteDescription(new RTCSessionDescription(offer));
myConnection.createAnswer(function (answer) {
myConnection.setLocalDescription(answer);
send({
type: "answer",
answer: answer
});
}, function (error) {
alert("oops...error"); //<-- this alert fires all the time
});
I have googled this and all I have found is set new RTCPeerConnection(configuration, { optional: [{RtpDataChannels: false}] }) but if I do so then when I try to send a message it says that dataChannel.readyState is not openned.
What do I do wrong? Any help appriciated!
Thanks!
Remove optional: [{RtpDataChannels: true}] and then wait for the datachannel.onopen event to fire before attempting to send messages.

Domain=org.webrtc.RTCPeerConnection Code=-1 "Failed to set remote offer sdp: Failed to set remote video description send parameters."

I keep getting this error on my iOS webrtc app using the webrtc when I take the sdp and try to set it as remote description. I've tried adjusting the sdp cause I thought it wasn't able to parse the string but it didn't work.
peerConnection = prepareNewConnection();
peerConnection.setRemoteDescription(sdp) { (Error) in
if Error != nil{
print("sdp creation error: \(String(describing: Error!.localizedDescription))")
}
}

"error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)",

I am getting below error while following tutorial here.
https://hyperledger.github.io/composer/unstable/managing/current-participant.html
I have created one Participant and issued identity to it. But in my transaction processor function,when I verify the participant ID of the current participant by using the getCurrentParticipant function through rest apis I get below error.
{
"error": {
"statusCode": 500,
"name": "Error",
"message": "error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)",
"stack": "Error: error trying invoke chaincode. Error: chaincode error (status: 500, message: TypeError: cannot read property 'getFullyQualifiedIdentifier' of null)\n at _initializeChannel.then.then.then.then.catch (/home/praval/.nvm/versions/node/v6.11.1/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:847:34)"
}
}
Can anybody explain the reason?
It looks like the mapping from certificate to participant is not in place. The easiest way to test this is to use the composer identity issue command and then use composer network ping -- which will return the current participant. Once that is working then getCurrentParticipant() should work.
https://hyperledger.github.io/composer/managing/identity-issue.html
When you composer network ping your participant will try to access the network metadata. The ACL rule below will permit this access. Please ensure that you are using the latest version of the basic-sample-network which includes this rule.
rule SystemACL {
description: "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

Can't get GCM push messages being sent properly

So my GCM push message works if I use this test link
http://www.androidbegin.com/tutorial/gcm.html
Here's the response
{ "multicast_id":7724943165862866717,
"success":1,
"failure":0,
"canonical_ids":0,
"results":[{"message_id":"0:1418649384921891% 7fd2b314f9fd7ecd"}]}
However if I push using my own service using node push service using the toothlessgear/node-gcm lib
https://github.com/ToothlessGear/node-gcm I get a success message on the server but no msg makes it to the client
{ multicast_id: 5130374164465991000,
success: 1,
failure: 0,
canonical_ids: 0,
results: [ { message_id: '0:1418649238305331%7fd2b3145bca2e79' } ] }
I also tried the same message using pushwoosh and push woosh doesn't work either. How come I'm getting a success message on the server, but no push is received on the client on the latter two services. Is there some sort of ip configuration that I need to do, or some sort of certificate? I've used the same google api server key which is open to all ips on all 3 of these services.
Why does the response show success on the latter but no msg gets received on the client?
Node service server side code
var gcm = require('node-gcm');
// create a message with default values
var message = new gcm.Message();
// or with object values
var message = new gcm.Message({
collapseKey: 'demo',
delayWhileIdle: true,
timeToLive: 3,
data: {
key1: 'message1',
key2: 'message2'
}
});
var sender = new gcm.Sender('insert Google Server API Key here');
var registrationIds = ['regId1'];
/**
* Params: message-literal, registrationIds-array, No. of retries, callback-function
**/
sender.send(message, registrationIds, 4, function (err, result) {
console.log(result);
});
So the pushes were correctly being sent, my issue was with the cordova plugin on the client which requires that the android payload for "message" or "title" be set. The sample php just coincidentally was setting the message property and that's why it worked.
Updating the code to add the following to the data
data: {message:'test'}
works correctly

jQuery .ajax call returning error when accessing Java Spring service via domain name based URL

My application's HTML5, jQuery Mobile frontend talks to Java server (Spring, Hibernate, MySQL). The application works fine on my notebook as well as in QA environment. On QA, I'm accessing the application using the server's IP address.
When I host the application in Live environment (the same server as QA but a different web app in Tomcat) and try to access it using URL with the domain name, $.ajax calls in the application return error.
One of the calls is as follows:
$.ajax({
type : "GET",
url : "http://www.smartcloudlearning.mobi:9080/SmartCloudLearningMobi/rest/resource/getResourceTypes",
cache : false,
async : false,
dataType : 'json',
success : function(rTypes) {
Alert("success!");
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert("An error has occurred making the request: " + errorThrown);
}
});
I get the following error in Firefox:
An error has occurred making the request: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://www.smartcloudlearning.mobi/js/jquery-1.7.1.min.js :: <TOP_LEVEL> :: line 4" data: no]
I get the following error in Chrome:
An error has occurred making the request: Error: NETWORK_ERR: XMLHttpRequest: Exception 101
In the server log, I see that the requested Spring service was successfully invoked but it looks like the client doesn't receive the data!
If I hit the URL
http://www.smartcloudlearning.mobi:9080/SmartCloudLearningMobi/rest/resource/getResourceTypes
directly in the browser, I get expected results! I sense that this is somehow due to how I forward server request from Apache to Tomcat.
The following are the lines in Apache / httpd server's httpd.conf file:
ProxyPass /SmartCloudLearningMobi http://www.smartcloudlearning.mobi:9080/SmartCloudLearningMobi
ProxyPassReverse /SmartCloudLearningMobi http://www.smartcloudlearning.mobi:9080/SmartCloudLearningMobi
Can anyone tell me what's amiss here? Much appreciated!
I managed to solve the problem:
The browser was giving the error on .ajax call because I had port number in my URL. The port number got carried over when I created 'live' URL from my QA URL. When I removed the port number from the .ajax call's URL, the call started returning success!
Jason Foglia, your statement "... and also the port..." nudged me to explore that angle... thanks a lot!
You're probably getting an error because of a security concept called "same origin policy" which doesn't allow you to call a service from a different domain. Or at least, disallow you from calling a method in that service.
Same discussion is found here - AJAX Cross Domain
You can however implement a cross-domain using JSONP - Wikipedia on JSONP
The solution is to change the datatype to JSONP:
$.ajax({
url:"http://www.smartcloudlearning.mobi:9080/SmartCloudLearningMobi...",
dataType: 'jsonp',
...
});
Try using an relative url:
If that doesn't work is the domain name the same as the url and also the port.
Browsers don't allow cross domains.
$.ajax({
type : "GET",
url : "/SmartCloudLearningMobi/rest/resource/getResourceTypes",
cache : false,
async : false,
contentType : "application/json"
dataType : 'json',
success : function(rTypes) {
Alert("success!);
},
error : function(XMLHttpRequest, textStatus, errorThrown) {
alert("An error has occurred making the request: " + errorThrown);
}
});
The browser was giving the error on .ajax call because I had port number in my URL. The port number got carried over when I created 'live' URL from my QA URL. When I removed the port number from the .ajax call's URL, the call started returning success!
Jason Foglia, your statement "... and also the port..." nudged me to explore that angle... thanks a lot!