Android ektorp couchbase replication error - android

I try to use ektorp client for replication in android and I have an error :
org.ektorp.DocumentNotFoundException: nothing found on db path: /_replicate, Response body: {"error":"not_found","reason":"unknown URL"}
I installed a gateway and a CouchBase server.
I access to the url /sync_gateway, but the client try to reach /sync_gateway/_replicate.
What's this ??? and what I have to do to make it work ????
Thank you by advance
Best regards
My code :
// start Ektorp adapter
HttpClient httpClient = new AndroidHttpClient.Builder()
.host("XXX")
.username("XXX")
.password("XXX")
.port(4984)
.build();
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
// create a local database
CouchDbConnector dbConnector = new StdCouchDbConnector("sync_gateway", dbInstance);
// pull this database to the test replication server
ReplicationCommand pullCommand = new ReplicationCommand.Builder()
.source("sync_gateway")
.target("XXX")
.continuous(true)
.build();
ReplicationStatus status = dbInstance.replicate(pullCommand);

Related

Xamarin.Android Mqtt Client with TLS Unauthorized result

I'm basically new to mobile development and stuck for a few weeks because,
I am unable to connect XAMARIN Android app with MQTTT over TLS.
Maybe i am using the wrong library or is it an Xamarin error?
My certificate is a .crt file from m21.cloudmqtt.com.
https://crt.sh/?id=5253106089
First was using System.Net MQTT but they are currently unable to work over TLS.
So i currently i am using MQTTNet, with (for the moment) the default certificate from m21.cloud.com which i have stored in Assets folder.I tested this local with and without a certificate and its working fine.
The MQTTNet Client with cert from local folder is like this, and works like it should:
var caCert = new X509Certificate2("C:/pathtocert.crt");
var source = new CancellationTokenSource().Token;
var token = source;
var factory = new MqttFactory();
var mqttClient = factory.CreateMqttClient();
var mqttOptions = new MqttClientOptionsBuilder()
.WithTcpServer(server, port)
.WithClientId(clientId)
.WithCredentials(username, pswd)
.WithTls(new MqttClientOptionsBuilderTlsParameters
{
UseTls = true,
Certificates = new List<X509Certificate> { caCert }
})
.Build();
mqttClient.ConnectAsync(mqttOptions, token).Wait(token);
To get the Certifcate from Android Assets Folder i used the same client code as above and t et the certificate i used:
using (var assetStream = await Xamarin.Essentials.FileSystem.OpenAppPackageFileAsync("filename.crt"))
using (var memStream = new MemoryStream())
{
assetStream.CopyTo(memStream);
caCert = new X509Certificate(memStream.ToArray());
}
I dont understand why its not working, for now its also okay if the certificate isn't used but it needs to use TLS. But tried, and i still get unauthorized error.
var mqttOptions = new MqttClientOptionsBuilder()
.WithTcpServer(server, port)
.WithClientId(clientId)
.WithCredentials(username, pswd)
.WithTls(new MqttClientOptionsBuilderTlsParameters
{
UseTls = true,
})
.Build();
Thanks in adnvance.

Endpoints generated client library

My problem is that I migrated to Endpoints v2, and at some point down the line my GCM registration code stopped working.
Stopped working? More specifically, the generated client library is attempting to send a POST request in the form provided in the top line of this image:
The second line is what happens when I send the request myself manually with Postman (changing it so that it sends the data in the URL fragment instead of in the query string). This works, and is added to my database.
The registration is sent using the standard API builder:
Registration.Builder builder = new Registration.Builder(AndroidHttp.newCompatibleTransport(), new AndroidJsonFactory(), null)
.setRootUrl("https://"+Constants.PROJECT_ID+".appspot.com/_ah/api/");
regService = builder.build();
regService.registerDevice(gcmRegistrationId).execute();
The endpoint itself looks like this:
#ApiMethod(name = "registerDevice", httpMethod = "post")
public void registerDevice(#Named("regId") String regId) {
if(findRecord(regId) != null) {
log.info("Device " + regId + " already registered, skipping register");
return;
}
RegistrationRecord record = new RegistrationRecord();
record.setRegId(regId);
ofy().save().entity(record).now();
}
How can this be resolved?
My code is being deployed and generated with the following commands:
gradlew endpointsOpenApiDocs
gcloud endpoints services deploy backend\build\endpointsOpenApiDocs\openapi.json
gradlew appengineDeploy
gradlew endpointsClientLibs
If you want the parameter to be a query string, it should be marked #Nullable as well. This will tell take the parameter out of the path. Looks like there is some mismatch between the configuration in the old and new frameworks, but it is more correct to use #Nullable for query parameters and omit it for path parameters.

Register pjsip account using Tls setting in pjsua

I am using Pjusa for Voip, I have done communication through UDP and TCP but could not communitcate through TLS setting`
TlsConfig tlsConfig = new TlsConfig();
File cacheDir = new File(ctx.getCacheDir(), "ca");
InputStream input = ctx.getResources().openRawResource(R.raw.ca);
tlsConfig.setCaListFile(cacheDir.getPath());
input = ctx.getResources().openRawResource(R.raw.secure);
cacheDir = new File(ctx.getCacheDir(), "secure");
tlsConfig.setCertFile(cacheDir.getPath());
tlsConfig.setMethod(pjsip_ssl_method.PJSIP_SSLV23_METHOD);`
I have attached CaListFile and setCertFile files like that method and that setting working but When I establish a call then I found error like that
tlsc0x9e7db014 TLS connect() error: Connection refused [code=120111]
tsx0x9d945864 Failed to send Request msg INVITE/cseq=25416 (tdta0x9d991000)! err=120111 (Connection refused)
In IOS I found some more setting for TLS , but could not implement in PJSUA
any one can help me out how to use that piece of code in android in PJSUA library
pj_sockaddr_in remote;
pjsip_transport *transport;
remote.sin_family = pj_AF_INET();
remote.sin_zero_len = 0;
remote.sin_addr.s_addr = pj_inet_addr(#"xxx.xx.xx.xx").s_addr;
remote.sin_addr.s_addr = INADDR_ANY;
bzero(&(remote.sin_zero),sizeof(remote.sin_zero));
app_config->cfg.use_srtp = PJMEDIA_SRTP_MANDATORY;
app_config->cfg.srtp_secure_signaling = 1;
thanks in advance
TlsConfig tlsConfig = new TlsConfig();
tlsConfig.setCertFile(certFile);
sipTpConfig.setTlsConfig(tlsConfig);
tlsConfig.setCaListFile(caListFile);
I did R&D from web searching and reading document of SIP and PJSIP, then I find the sluotion for accountConfig for PJMEDIA_SRTP_MANDATORY and setSrtpSecureSignaling(1) by that way provided below
accCfg.getMediaConfig().setSrtpUse(pjmedia_srtp_use.PJMEDIA_SRTP_MANDATORY);
accCfg.getMediaConfig().setSrtpSecureSignaling(1);
Hence TLS working with CAListFile and CertificateFile

How to post the data in Node.js from android using retrofit

I am posting the data from Android to the Node.js. I am successfully able to call the Node.js post method and using restify able to get the Post data.
But when doing through express I am not able to get the post body in Node.js. I tried for many approaches from SO post but it seems none are working may be I am missing something.
The snippets are like:
Node.js
var express = require('express')
var request = require('request')
var http = require('http')
var bodyParser = require('body-parser')
var app = express();
app.set('port', (process.env.PORT || 5000))
app.use(express.static(__dirname + '/public'))
app.use(bodyParser.urlencoded())
app.use(bodyParser.json())
app.post('/search/addcomplaint',addComplaint)
function addComplaint(req,res,next){
console.log(req.body);
if (!req.body) return res.sendStatus(400)
res.send(201,user)
}
app.listen(app.get('port'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
})
at Android Site I am making a retrofit call like this:
#Multipart
#POST("/search/addcomplaint")
public User search(#Part("complaint") String complaint);
when I used restify in Node.js I was able to get req.body but using express I am not getting the request body.

Send file is done but actually fail in Asmack android

This is how I try to send a file over XMPP using asmack lib (from the GtalkSms project) and a Ejabberd server:
//Configure provider in onCreate()
configure(ProviderManager.getInstance());
// Configure function
private void configure(ProviderManager pm){
pm.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
pm.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
pm.addIQProvider("open","http://jabber.org/protocol/ibb", new OpenIQProvider());
pm.addIQProvider("close","http://jabber.org/protocol/ibb", new CloseIQProvider());
pm.addExtensionProvider("data","http://jabber.org/protocol/ibb", new DataPacketProvider());
}
// This is how I send file after login to server (I put everything below in a
function, inside a Thread and call thread.start() at the end of function):
// set the serviceDiscoveryManager
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(xmppConn);
if (sdm == null){
sdm = new ServiceDiscoveryManager(xmppConn);
}
sdm.addFeature("http://jabber.org/protocol/disco#info");
sdm.addFeature("jabber:iq:privacy");
// Create the file transfer manager
FileTransferManager manager = new FileTransferManager(connection);
FileTransferNegotiator.setServiceEnabled(connection, true);
OutgoingFileTransfer transfer = manager
.createOutgoingFileTransfer(Receiver
+ "#MyDomain");
transfer.sendFile(new File(myFilePath), "myDescription");
If I use another client to test the file transfer (http://coccinella.im/), then I can chat and send a file over my Ejarbberd server between (2 coccinella clients). If I use a coccinella client and my client in android, I can chat between them and I can receive file sent from coccinella client to my android client. However, when I try to send file from my android client to the coccinella client, transfer.isDone() always returns true and transfer.getStatus() == Status.error also returns true.
So what's happen to my Android client? Did I use wrong library? Or I missed something?
Edited: This is what I got from debugger: <iq id="QgJIb-29" to="phuocdh#localhost/Smack" from="phuoctest#localhost/Coccinella#phuocdh-pc" type="error"><error code="404" type="CANCEL"><item-not-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><query xmlns="http://jabber.org/protocol/bytestreams"><streamhost></streamhost></query></error></iq>

Categories

Resources