have any idea how to make a socket.get() request in android?
I try this:
JSONObject obj = new JSONObject();
obj.put("url","/controller/action");
socketClient.emit("get",obj);
And the server response is:
Error (SAILS:HOOK:SOCKETS:PARSE_VIRTUAL_REQ):: Failed to parse incoming socket.io request
...
details: 'Sails v0.11.x is not compatible with the socket.io/sails.io.js client SDK version you are using (0.9.0). Please see the v0.11 migration guide on http://sailsjs.org for more information.'
Just change your url to something like below
http://xxx.xxx.xxx.xxx:1234/?__sails_io_sdk_version=0.11.0
For some reason the version is not available in the SDK META DATA information. In the file node_modules\sails\node_modules\sails-hook-sockets\lib\parse-sdk-metadata.js there is a code which checks if version is not available in the meta data then assume the version is 0.9.0
if (!handshake.query[SDK_META_PARAMS.version]) {
handshake.query[SDK_META_PARAMS.version] = '0.9.0';
}
So i changed 0.9.0 to 0.11.0 and voila! things are working.
I don't know about socket.get() request in android.
But I know that if your server is running v.0.11 of Sails, you need to upgrade your sails.io.js client to v0.11, as v0.9 is not compatible.
It's explained in the migration guide, with instructions on how to upgrade: sails generate sails.io.js --force. All the details are in the link:
https://github.com/balderdashy/sails/blob/master/0.11-migration-guide.md#differences
Related
I am new to Realm and Android development and am trying to query a document from Atlas. I am able to successfully authenticate users, but when I try to perform a query, I get the following error: E/REALM_JAVA: Session Error[wss://realm.mongodb.com/]: WRONG_PROTOCOL_VERSION(realm::sync::ProtocolError:105): sync client must have a sync protocol version of at least 3 to sync on this application, but found version 2. Please update your application to use a newer SDK
I am currently working on version 10.4.0 of the Android Realm SDK and Android SDK Platform 30. I have tried looking for updates for both and it says that everything is up to date. Here is my code:
app.loginAsync(emailPasswordCredentials, it -> {
if (it.isSuccess()) {
Log.v("AUTH", "Successfully authenticated using an email and password.");
User user = app.currentUser();
String partitionValue = "object_id";
SyncConfiguration config = new SyncConfiguration.Builder(
user,
partitionValue)
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.build();
uiThreadRealm = Realm.getInstance(config);
//Debugging - testing Realm Sync queries
Products product = uiThreadRealm.where(Products.class).equalTo("_id", 4).findFirst();
if (product != null) {
Log.v("AUTH", product.toString());
}
Log.v("AUTH", config.toString());
//In-App functions
}
Does anyone have any way to solve this issue?
In my case it was due to selecting UUID as the type of one my fields, which is "at this time is NOT a supported type in the SDK, but it will be in a future version." (from Monogo's support).
For those coming from react-native and get this kind of error
sync client must have a sync protocol version of at least 3 to sync on this application, but found version 2. Please update your application to use a newer SDK
Just do in your terminal
npm install realm
Then
cd ios
pod install
Be careful of breaking changes.
If needed, uninstall your application on your emulator/simulator then
npx react-native run-ios
or
npx react-native run-android
So for Android I guess you have to update your Realm packages as well...
I'm trying to use grpc in an Android App
The important part of the code is this:
private val managedChannel: ManagedChannel = ManagedChannelBuilder
.forTarget("misserverurl.com")
.build()
build.gradle with version and dependencies:
minSdkVersion 19
implementation "io.grpc:grpc-okhttp:1.26.0"
implementation "io.grpc:grpc-protobuf:1.26.0"
implementation "io.grpc:grpc-stub:1.26.0"
The protos seems okay, and the app works without TLS (.usePlaintext())
But I'm getting this error:
java.lang.RuntimeException: TLS ALPN negotiation failed with protocols: [grpc-exp, h2]
Where it seems there is a problem with the SSL handshake.
The weird part is that the server works using BloomRCP using TLS.
I've tried with different minSdkVersions, also using different io.grpc.* lib versions and creating an empty repo with just the proto files and the basic code to run it but nothing and adding .connectionSpec() with different CipherSuite as well.
Using Wireshark I could see that the TLS version that I'm sending is 1.2 which is correct and expected (maybe it's not using HTTP2?)
Any guest?
Thanks in advance!
--------------------------------------------------- Edit ---------------------------------------------------
Look into the lib I've found this method: useTransportSecurity()
/**
* Sets the negotiation type for the HTTP/2 connection to TLS (this is the default).
...
*/
#Override
public final OkHttpChannelBuilder useTransportSecurity() { ... }
We are using TLS with HTTP/2 by default, so that's not the problem...
HTTP/2 is negotiated during TLS using ALPN. The client sends what protocols it supports (in this case grpc-exp and h2, aka http/2). The server then selects what protocol, or none. If none is selected then the only options are to fall back to another protocol like HTTP/1 or to fail.
gRPC requires HTTP/2, so the server must select 'h2' via ALPN. The error is that didn't happen. Your server needs to support HTTP/2. If you are using a TLS terminator or you are using an L7 load balancer, you must configure it to support HTTP/2.
Finally it was a backend issue.
Following this: https://www.getambassador.io/reference/core/tls/#alpn_protocols
The alpn_protocol was set like this:
alpn_protocol = h2[, grpc-epx]
Where it should be:
alpn_protocol = h2
With that and this config in client side, it worked!
private val managedChannel: ManagedChannel = ManagedChannelBuilder
.forTarget("misserverurl.com")
.build()
Encountered this issue before when using java 1.8.0_242-b08, after upgrade to 1.8.0_265, no issue
I've been trying to use apollo client on my react-native project so that I can connect to a fully developed apollo graphql server. However I'm getting an error that suggests that createNetworkInterface is not the correct way to do it. How should I initialize the apollo client? Error from the debugging mobile device
The code that I used to initialize the apollo client is:
// Initialize the Apollo Client
const client = new ApolloClient({
networkInterface: createNetworkInterface({
uri: 'https://api.graph.cool/simple/v1/ciwce5xw82kh7017179gwzn7q',
}),
})
I have really tried my best to look for solutions on how to implement this, but most tutorials/documentations are for react for web and none is for react-native. Sorry about my bad English :(
I've had the same issue some time back. Unfortunately I couldn't find any other solution other than to downgrade my react-apollo and react-native dependencies as below:
yarn add react-apollo#1.0.0
and also install an older version of react-native:
react-native init appName --version react-native#0.45.0
You could also refer to some thread on this issue here and here.
We know that Android M has removed support for HttpClient. Apps linking with it will have to explicitly say so: add a library dependency in your gradle file.
But does it break backward compatibility with existing applications?
Suppose I wrote an app which supports Api level 1 and higher and it's never maintained since last year. The targetSdkLevel of the app is certainly lower than 22. Will it crash on Android M? The source code could have been lost.
The answer looks to be yes.
I looked in the Android M source code through the SDK manager, and the package for the client is not in the source.
Package name for the HttpClient:
org.apache.http.client.HttpClient
Existing paths:
org.apache.http.conn
org.apache.http.params
Ways to fix this:
Add this to your build.graddle:
android {
useLibrary 'org.apache.http.legacy'
}
Use OkHttp-UrlConnection as an almost drop in replacement by adding this to your build.graddle:
compile 'com.squareup.okhttp:okhttp-urlconnection:2.4.0'
Example usage:
private static OkHttpClient okHttpClient = new OkHttpClient();
HttpURLConnection urlConnection = new OkUrlFactory(okHttpClient).open(url);
While following the steps outlined here :
https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial/
for creating a cloud endpoint, but using Android Studio instead of Eclipse, I am stuck at Step 9 of the Entity Class Design Pattern as described here :
https://cloud.google.com/developers/articles/how-to-build-mobile-app-with-app-engine-backend-tutorial/#ecdp
In Eclipse, there is a right-click-menu-option for "Generate Cloud Endpoint Client library" when you right-click on the app engine project. However, there is no equivalent option in Android Studio (v1.0.0)
Is this an omission on Google's part or am I missing something.
What is the best workaround for generating the cloud endpoint client library from within Android Studio.
Is there a way to do it from the command-line?
I did find the steps for gradle here :
https://cloud.google.com/appengine/docs/java/endpoints/endpoints_tool
and here :
https://cloud.google.com/appengine/docs/java/endpoints/consume_android
but these are much more time-consuming than the single-step process described in the original link for eclipse.
As stated above the libraries are auto-compiled for you, the other point to note that had me confused is where to get the Builder from.
Now as of Android Studio 1.0.1 the original Eclipse instructions are a little out of date for this as well, the "Builder" is no longer buried into the Endpoint class you make. Instead it is rolled into a separate API class to describe the Builder and associated code.
See: https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloEndpoints
Endpoint Usage from Android would now look like this:
/* OLD
MyEndpoint.Builder builder = ... */
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
We're working on updating that shopping kart sample to use Android Studio.
In the meantime the documentation for generating endpoints in AS can be found here https://cloud.google.com/tools/android-studio/
There is no 'Generate Cloud Endpoint Client Library' task anymore since it's not needed in the Android Studio workflow. Simply building the project will ensure that the client libraries are available to your android app.
Check out the docs for the appengine gradle plugin https://github.com/GoogleCloudPlatform/gradle-appengine-plugin if you want to be able to manually perform some of the endpoint client library steps from the command line using Gradle.
As Lucien Murray-Pitts explained, the Builder is not in the Endpoint class but in a auto-generated XXXXApi class.
Imagine your java bean is a class called Portfolio under package com.example.backend
You have to add the following import in the AsyncTask class:
import com.example.backend.portfolioApi.PortfolioApi;
and then you can do
PortfolioApi.Builder builder = new PortfolioApi.Builder(....