Binding a Java gRPC server to a unix domain socket - sockets

I have the following, which creates a Java gRPC server and attempts to bind it to the USD /tmp/foo:
EpollEventLoopGroup group = new EpollEventLoopGroup();
Server server =
NettyServerBuilder.forAddress(new DomainSocketAddress("/tmp/foo"))
.channelType(EpollServerSocketChannel.class)
.bossEventLoopGroup(group)
.workerEventLoopGroup(group)
.addService(new Impl())
.build()
.start();
server.awaitTermination();
However, this fails with bind(..) failed: Invalid argument:
Exception in thread "main" java.io.IOException: Failed to bind
at io.grpc.netty.NettyServer.start(NettyServer.java:231)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:151)
at io.grpc.internal.ServerImpl.start(ServerImpl.java:75)
at com.google.devtools.javatools.jade.pkgloader.GrpcLocalServer.main(GrpcLocalServer.java:60)
Caused by: io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Invalid argument
at io.netty.channel.unix.Errors.newIOException(Errors.java:117)
at io.netty.channel.unix.Socket.bind(Socket.java:291)
at io.netty.channel.epoll.AbstractEpollChannel.doBind(AbstractEpollChannel.java:714)
at io.netty.channel.epoll.EpollServerSocketChannel.doBind(EpollServerSocketChannel.java:70)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1283)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:989)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:364)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:309)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
at java.lang.Thread.run(Thread.java:745)
I checked that the file /tmp/foo doesn't exist, that I have write permissions to it and its parent directory, and that no process is bound to it (netstat -na | grep /tmp/foo.socket). I'm on a Linux system.
Am I missing something obvious?

Using EpollServerDomainSocketChannel instead of EpollServerSocketChannel fixed the issue.
For easy future copy/paste, the following binds (listens) to a UDS:
EpollEventLoopGroup group = new EpollEventLoopGroup();
Server server = NettyServerBuilder.forAddress(new DomainSocketAddress("/tmp/foo"))
.channelType(EpollServerDomainSocketChannel.class)
.workerEventLoopGroup(group)
.bossEventLoopGroup(group)
.addService(new Impl())
.build()

Related

how to pass start parameter into my kubernetes pod service

If I start the service using docker,It should look like this:
docker run -e PARAMS="--spring.datasource.url=jdbc:mysql://mysql-service.example.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>" -p 8180:8080 -v /tmp:/data/applogs --name xxl-job-admin -d xuxueli/xxl-job-admin:2.0.2
now I am running it in kubernetes(v1.15.2) cluster,how to pass the parameter into pod's container? I am trying to pass parameter like this:
"name": "xxl-job-service",
"image": "xuxueli/xxl-job-admin:2.0.2",
"args": [
"--spring.datasource.url=jdbc:mysql://mysql-service.ttt208.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>"
],
but it seem do not work,it throw :
19:19:55.563 logback [xxl-job, admin JobFailMonitorHelper] ERROR c.x.j.a.c.t.JobFailMonitorHelper - >>>>>>>>>>> xxl-job, job fail monitor thread error:{}
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
### The error may exist in class path resource [mybatis-mapper/XxlJobLogMapper.xml]
### The error may involve com.xxl.job.admin.dao.XxlJobLogDao.findFailJobLogIds
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy57.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy61.findFailJobLogIds(Unknown Source)
at com.xxl.job.admin.core.thread.JobFailMonitorHelper$1.run(JobFailMonitorHelper.java:49)
at java.lang.Thread.run(Thread.java:748)
what should I do to run this service success? I am sure the database username and password correct.
Dockers -e or --env sets an environment variable.
The equivalent in a Kubernetes pod spec is the containers env field
env:
- name: PARAMS
value: ' --spring.datasource.url=jdbc:mysql://mysql-service.example.com/xxl-job?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=<mysql-password>'

If gemfire.properties is specified then Geode locator fails to start

I am working through the SSL example which means starting the locator using the properties files instead of default. So it's
start locator --name=IsLocator --properties-file=..\config\gemfire.properties --security-properties-file=..\config\gfsecurity.properties
Then whether the SSL is set in the properties files or not, this causes the locator process to terminate with an error
The Locator process terminated unexpectedly with exit status 1. Please refer to the log file in D:\Geode\bin\IsLocator for full details.
Sep 21, 2017 11:23:22 AM org.apache.geode.distributed.LocatorLauncher failOnStart
INFO: locator is exiting due to an exception
java.lang.RuntimeException: java.io.IOException: Unable to write to deploy directory: D:\tmp
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:410)
at org.apache.geode.internal.cache.GemFireCacheImpl.initialize(GemFireCacheImpl.java:1191)
at org.apache.geode.internal.cache.GemFireCacheImpl.basicCreate(GemFireCacheImpl.java:758)
at org.apache.geode.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:745)
at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:173)
at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:212)
at org.apache.geode.distributed.internal.InternalLocator.startCache(InternalLocator.java:723)
at org.apache.geode.distributed.internal.InternalLocator.startDistributedSystem(InternalLocator.java:710)
at org.apache.geode.distributed.internal.InternalLocator.startLocator(InternalLocator.java:324)
at org.apache.geode.distributed.LocatorLauncher.start(LocatorLauncher.java:651)
at org.apache.geode.distributed.LocatorLauncher.run(LocatorLauncher.java:553)
at org.apache.geode.distributed.LocatorLauncher.main(LocatorLauncher.java:195)
Caused by: java.io.IOException: Unable to write to deploy directory: D:\tmp
at org.apache.geode.internal.JarDeployer.verifyWritableDeployDirectory(JarDeployer.java:333)
at org.apache.geode.internal.JarDeployer.loadPreviouslyDeployedJarsFromDisk(JarDeployer.java:389)
... 11 more`
The same error happens if GFSH is started as an administrator.
This problem resolves if you remove the deploy-working-dir property.

Failed to open native connection to Cassandra from jar produced by intellij

I've developed a spark-based application that gets data from kafka and saves it in cassandra DB, using intellij.
connection code in scala:
val cluster = Cluster.builder().addContactPoint("192.168.0.253").withPort(9042).build();
val session = cluster.connect()
the code work fine when I run it from intellij, but I get this error when I try to run it from jar using command line:
Exception in thread "main" java.io.IOException:
Failed to open native connection to Cassandra at {192.168.0.253}:9042 at .... ....
Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException:
All host(s) tried for query failed
(tried: /192.168.0.253:9042 (com.datastax.driver.core.exceptions.TransportException:
[/192.168.0.253] Error writing)) at
com.datastax.driver.core.ControlConnection.reconnectInternal(
ControlConnection.java:233) at
com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:79)
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1424)
at com.datastax.driver.core.Cluster.getMetadata(Cluster.java:403)
at com.datastax.spark.connector.cql.CassandraConnector$.
com$datastax$spark$connector$cql$CassandraConnector$$createSession(
CassandraConnector.scala:155) ... 13 more
I've produced a jar file from intellij, and I built the jar with dependencies, using [ copy to the output directory and link via manifist ] option.
cassandra.yaml file:
#Whether to start the native transport server.
start_native_transport: true
#port for the CQL native transport to listen for clients on
native_transport_port: 9042
Why is this error raised & and how can I fix it?
Thanks in advance

Error using SoapClient() in PHP

I'm trying to access WSDL(Web Service Definition Language) file using SoapClient() of PHP. I found that WSDL file is authenticated. I tried with passing credentials on an array by another parameter and active SSL on my server, still I'm getting an error.
Here is the code I'm using:
$client = new
SoapClient("https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl",array("trace"
=> "1","Username" => "username","Password" => "password"));
Here is the error I'm getting:
Warning:
SoapClient::SoapClient(https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl)
[soapclient.soapclient]: failed to open stream: Connection timed out
in PATH_TO_FILE on line 80
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning
: failed to load external entity
"https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl"
in PATH_TO_FILE on line 80
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from
'https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl'
: failed to load external entity
"https://webservices.chargepointportal.net:8081/coulomb_api_1.1.wsdl"
in PATH_TO_FILE:80 Stack trace: #0
/home2/wingstec/public_html/widget/API/index.php(80):
SoapClient->SoapClient('https://webserv...', Array) #1 {main} thrown
in PATH_TO_FILE on line 80
It seems that error says file not exist at the path we given but when we run that path directly on browser then we're getting that file
Can anyone help me to figure out what the exactly problem is?
First make sure you have the right to access website from your hosting account or server - check first if you can access a http webservice (without the s). If not, check if allow_url_fopen is set to true in php.ini.
Then, if you are trying to establish a https connection, you need a local certificate.
See if you can add one and instantiate your Soap object using something like
new SoapClient($wsdl, array('local_cert' => $pathToLocalCert));

DEBUG [org.jboss.naming.Naming] Error writing response to /127.0.0.1 java.net.SocketException

After starting the run/debug configuration begins build and deploy application. All goes well. The only thing that provides continuously JBoss Log SocketException:
2012-07-16 12:43:30,424 DEBUG [org.jboss.naming.Naming] Error writing response to /127.0.0.1 java.net.SocketException: Software caused connection abort: socket write error at java.net.SocketOutputStream.socketWrite0(Native Method) at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92) at java.net.SocketOutputStream.write(SocketOutputStream.java:136) at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847) at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1756) at java.io.ObjectOutputStream.writeNonProxyDesc(ObjectOutputStream.java:1257) at java.io.ObjectOutputStream.writeClassDesc(ObjectOutputStream.java:1211) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1395) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158) at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1547) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333) at org.jnp.server.Main$BootstrapRequestHandler.run(Main.java:516) at org.jboss.util.threadpool.RunnableTaskWrapper.run(RunnableTaskWrapper.java:148) at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756) at java.lang.Thread.run(Thread.java:662)
At issues.jboss.org/browse/JBAS-3417 offer a solution:
If you set server / etc / host with:
IP fqn name
where IP is in «Error writing response to / IP"
Ex:
... "Error writing response to / 10.1.0.1"
10.1.0.1 test.mydomain test
you resolve the problem
But I have something 127.0.0.1 localhost, it is already registered in the default c:\ Windows\system32\drivers\etc\hosts
In the Troubleshooting says:
You may notice something in the JBoss logs similar to the following:
2009-01-28 08:36:57,381 DEBUG
[org.jboss.naming.NamingService]
Error writing response to / 127.0.0.1 <[http://127.0.0.1]>
java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0 (Native Method)
This is most likely an anomalous and benign «problem». That is, it should not affect the operation of any applications deployed to JBoss.
If this does not affect deployed application can be any way to hide it? And then the continuous output overshadows the other posts and eats memory.