Cannot connect to MobileFirst Server during initialization - ibm-mobilefirst

I am testing developing a Hybrid application in MobileFirst Studio and want to connect to MobileFirst Server during the app init. I updated main.js file under MF_Project/app/[appNanme]/common/js/main.js init method with the following:
WL.Client.connect({
onSuccess: function() {
WL.Logger.info("onSuccess: connection success");
},
onFailure: function(err) {
WL.Logger.info("onFailure: Exception: " + err);
}
});
I then build the app for Android environment (right click the appName the one under MF_Project and select "Build for Android environment"). Then I ran the app as Android Application in emulator, but the log comes back with error
01-25 16:04:29.364: E/NONE(2755): Invalid invocation of method WL.Client.connect; Invalid value 'undefined' (undefined), expected type 'function'.
01-25 16:04:29.368: E/NONE(2755): Invalid invocation of method WL.Client.connect; Invalid options attribute 'onSuccess'. Invalid invocation of method WL.Client.connect; Invalid value 'undefined' (undefined), expected type 'function'.
Any insight on this would be appreciated.

I have tested the supplied project in MFP 6.3 using a Nexus 5 device running Android 5.0.1.
The application successfully connected to the MFP Server.
In the log I saw the SUCCESSFUL: [object object] message.
[object object] because you did not JSON.stringify the result.
For example: WL.Logger.info("SUCCESSFUL: " + JSON.stringify(response));
I think something is wrong with your generated AVD - try to create a new one, in addition to testing in an actual device.

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.

Can't fetch data from local api React-Native

I have a web application, in react using an API made in Laravel. I want to make a mobile app using the same API. I can't fetch data, because I get NETWORK REQUEST FAILED error. This is how I try to fetch data:
handleButton = () => {
try {
fetch(`127.0.0.1:8081/test`).then(response =>
console.log(response)
);
} catch (e) {
console.log(e);
}
};
I tried changing the ip in dev settings to my machine id, i tried using localhost not the ip(127.0.0.1) but none of those fixed it... I can't seem to find anything else. Here is the error text:
Possible Unhandled Promise Rejection (id: 0):
TypeError: Network request failed
TypeError: Network request failed
at XMLHttpRequest.xhr.onerror (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:42556:18)
at XMLHttpRequest.dispatchEvent (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:47998:27)
at XMLHttpRequest.setReadyState (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:46859:20)
at XMLHttpRequest.__didCompleteResponse (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:46686:16)
at blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:46796:47
at RCTDeviceEventEmitter.emit (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:16875:37)
at MessageQueue.__callFunction (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:16488:44)
at blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:16245:17
at MessageQueue.__guard (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:16442:13)
at MessageQueue.callFunctionReturnFlushedQueue (blob:http://localhost:8081/cfc373de-8318-4df3-b46a-7b17d4926c5e:16244:14)
EDIT:
I am using android studio's emulator, because i don't have an android device running android > 5
Use the IP of your machine on the local network.
Open up terminal/cmd.
If you're using a mac, you can use ifconfig and it's usually under en0. You will see something like 192.168.0.32 or similar.
If you're using windows, you can use ipconfig.

Alamofire multipartFormData.append method raise Fatal error: Call of deleted method

I am using Alamofire and I use Alamofire for the http request and uploading image to the server.
Normally, I use simple http request, but today I checked uploading request.
I got the "Fatal error: Call of deleted method" and App was crashed.
This is my code.
Alamofire.upload(multipartFormData: { multipartFormData in
multipartFormData.append(imageData, withName: "image", fileName: "user_image", mimeType: "image/png")
if let params = params {
for (key, value) in params {
// This method raise "Fatal error: Call of deleted method"
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
}
}
}, to: path, encodingCompletion: { result in
})
The next code does not raise the error.
multipartFormData.append(imageData, withName: "image", fileName: "user_image", mimeType: "image/png")
But this code raise the error which said "Fatal error: Call of deleted method".
multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key)
Before today, this code did not raise the error.
I tried these.
First, I upgraded Alamofire 4.7.2 to 4.7.3.
But the result was same.
Second, This codes are defined in embedded frameworks, so I copy this method to App code directory.
But the result was same.
Environment
XCode 9.4.1
Carthage 0.30.1 to install Alamofire
I solved this problem.
I reinstalled XCode and Simulator, and fixed the problem.
I referenced these links.
How to Uninstall Xcode on macOS
xcode simulator not coming up - reinstall possible?

Mobile First Auto-update fails in iOS devices while changing the Server URL at run time

I'm working on an IBM MobileFirst Platform 7.1 project where we have many remote servers say, Dev, Test etc. The requirement was to change the servers at run time so that we would not be required to build and distribute multiple apps.
I followed the Official IBM tutorial.
Here is the code I use to connect to the server after the server is changed.
WL.Client.connect({onSuccess: function(){
WL.SimpleDialog.show(
"Connection Success", "Successfully connected to the server URL. Your app will reload once you press OK",
[{text: "OK", handler: function() {WL.Client.reloadApp();}}]
);
}, onFailure: function(error) {
WL.SimpleDialog.show(
"Connection Falied", error.status +" "+error.errorCode + " : " + error.errorMsg,
[{text: "Close", handler: function() {}}]
);
}});
It works perfectly fine in Android. But, in iOS devices, the server gets changed and gets connected to the new server. When the Auto-update runs in order to fetch the new code from the changed server, it gets Stuck indefinitely
Any help would be greatly appreciated. Thanks in advance.

How to use spiderable with a meteor app hosted on modulus.io

I'm trying to make spiderable works on my meteor app hosted on modulus with SSL.
I have Meteor 1.0, iron:router 1.0, spiderable and node package of phantomjs
All is working on localhost. But once I deploy on Modulus, first I had the error
spiderable: phantomjs failed: null
Then, I added the following environment variable in the modulus panel:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ssl-protocol=tlsv1 --ignore-ssl-errors=yes --debug=true
This is still not working and the debug is outputting multiple times (like it's looping over an error) the following message in the modulus console:
2014-12-03T17:01:00 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function () {
if (typeof Meteor === 'undefined'
|| Meteor.status === undefined
|| !Meteor.status().connected) {
return false;
}
if (typeof Package === 'undefined'
|| Package.spiderable === undefined
|| Package.spiderable.Spiderable === undefined
|| !Package.spiderable.Spiderable._initialSubscriptionsStarted) {
return false;
}
Tracker.flush();
return DDP._allSubscriptionsReady();
})(); })()"
2014-12-03T17:01:00 [DEBUG] WebPage - evaluateJavaScript result QVariant(bool, false)
If anyone knows how to solve this or succeeded to deploy a meteor project on modulus.io with SSL and spiderable. Let's me know the good way to do it :)
Thank a lot !
I solved my problem as follows:
I installed phantomjs locally and run the test script available at http://www.meteorpedia.com/read/spiderable/
phantomjs phantomtest.js
This gave me more details about the error: Parse Error.
Then, it was a javascript file that once compiled/minified, rendered an error caused by select2. The js library that was using it was flat-ui.js (http://designmodo.github.io/Flat-UI/).
I discover this by testing many deploys on *.meteor.com and by adding/removing .js file.
I edit the flat-ui.js library to avoid Parsing Error.
I redeployed on both modulus.io and *.meteor.com. All was working fine on *.meteor.com but still didn't work on modulus.io. That let me thinking about an SSL error but I only saw "spiderable: phantomjs failed: null" in the modulus.io logs.
I add the following environment variable in the modulus panel:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --debug=true
and it appears that it was a "SSL Handshake error":
[DEBUG] Network - Resource request error: 6 ( "SSL handshake failed" )
I add another option to the METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS environment variable:
METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ignore-ssl-errors=yes --debug=true
Now everything is working fine on modulus.io.
To sumup:
solve javascript errors
add METEOR_PKG_SPIDERABLE_PHANTOMJS_ARGS = --ignore-ssl-errors=yes
I hope this will help some dudes,