cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
597
Views
10
Helpful
2
Replies

Connecting to NSO running in Docker using Java maapi api expected 9 bytes from socket, only got -1

pralala
Cisco Employee
Cisco Employee

We get the following error when we try to connect from outside of container. NSO is running inside the container.We also have port forwarding done.. We have below configuration of docker. 


We get the following error when we try to connect from outside of container. NSO is running inside the container. We have below configuration of docker. Please check below the logs
java.lang.IllegalStateException: com.tailf.conf.ConfException: expected 9 bytes from socket, only got -1 at com.viptela.vmanage.FunctionalTest.getNewMaapi(FunctionalTest.java:74)
at com.viptela.vmanage.FunctionalTest.getNewMaapiAndStartTrans(FunctionalTest.java:168)
at com.viptela.vmanage.CliPreviewTest.testDay0(CliPreviewTest.java:67)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:744)
at org.testng.TestRunner.run(TestRunner.java:602)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:110)
Caused by: com.tailf.conf.ConfException: expected 9 bytes from socket, only got -1
at com.tailf.conf.ConfInternal.doConnect(ConfInternal.java:1362)
at com.tailf.maapi.Maapi.<init>(Maapi.java:266)
at com.viptela.vmanage.FunctionalTest.getNewMaapi(FunctionalTest.java:70)
... 26 more
~/Applications/viptela/viptela-0309 feature/dfp-mcast$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4271a4d7434f f2bda5208770 "/usr/sbin/init" 11 hours ago Up 11 hours 0.0.0.0:2022->2022/tcp, 0.0.0.0:2024->2024/tcp, 0.0.0.0:4569->4569/tcp vunit
~/Applications/viptela/viptela-0309 feature/dfp-mcast$ docker inspect vunit
[
{
"Id": "4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41",
"Created": "2020-03-27T05:59:06.0713266Z",
"Path": "/usr/sbin/init",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 3613,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-03-27T05:59:06.4403383Z",
"FinishedAt": "0001-01-01T00:00:00Z"
},
"Image": "sha256:f2bda52087707c8806a7accdcc05141e50a4041b06bf7108cf5b031510b91a42",
"ResolvConfPath": "/var/lib/docker/containers/4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41/hostname",
"HostsPath": "/var/lib/docker/containers/4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41/hosts",
"LogPath": "/var/lib/docker/containers/4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41/4271a4d7434f7db677b1f370305a15477707f57ea97c1a51798847d12c5fac41-json.log",
"Name": "/vunit",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": [
"/var/run/docker.sock:/var/run/docker.sock",
"/Users/bhairav/.m2:/root/.m2",
"/sys/fs/cgroup:/sys/fs/cgroup:ro",
"/Users/bhairav/Applications/viptela/viptela-0309:/viptela:cached"
],
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"2022/tcp": [
{
"HostIp": "",
"HostPort": "2022"
}
],
"2024/tcp": [
{
"HostIp": "",
"HostPort": "2024"
}
],
"4569/tcp": [
{
"HostIp": "",
"HostPort": "4569"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": [
"SYS_ADMIN"
],
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"Cgroup": "",
"Links": null,
"OomScoreAdj": 0,
"PidMode": "",
"Privileged": false,
"PublishAllPorts": false,
"ReadonlyRootfs": false,
"SecurityOpt": null,
"Tmpfs": {
"/run": "",
"/tmp": ""
},
"UTSMode": "",
"UsernsMode": "",
"ShmSize": 67108864,
"Runtime": "runc",
"ConsoleSize": [
0,
0
],
"Isolation": "",
"CpuShares": 0,
"Memory": 0,
"NanoCpus": 0,
"CgroupParent": "",
"BlkioWeight": 0,
"BlkioWeightDevice": [],
"BlkioDeviceReadBps": null,
"BlkioDeviceWriteBps": null,
"BlkioDeviceReadIOps": null,
"BlkioDeviceWriteIOps": null,
"CpuPeriod": 0,
"CpuQuota": 0,
"CpuRealtimePeriod": 0,
"CpuRealtimeRuntime": 0,
"CpusetCpus": "",
"CpusetMems": "",
"Devices": [],
"DeviceCgroupRules": null,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/27af7557c9ad0419936dcaf240fc36616504f3aa35b76d5073d3319b838133d9-init/diff:/var/lib/docker/overlay2/c240ff15adb263d3b91af86a2f3b2adcc8a148096d855da7cc23aecb481d3755/diff:/var/lib/docker/overlay2/0a040b89f6b41ab7949098256101450d0da474f4367af4c66588a6c602925b5e/diff:/var/lib/docker/overlay2/7ac2bc9f105b3b00f3404dd4de2d50001cc34d3b7e298b9028a93168b4857277/diff:/var/lib/docker/overlay2/bd1a0f3ff71adc15c2256bf8f0db093e96c53c1ef6a6879f39f82dd3410f5540/diff",
"MergedDir": "/var/lib/docker/overlay2/27af7557c9ad0419936dcaf240fc36616504f3aa35b76d5073d3319b838133d9/merged",
"UpperDir": "/var/lib/docker/overlay2/27af7557c9ad0419936dcaf240fc36616504f3aa35b76d5073d3319b838133d9/diff",
"WorkDir": "/var/lib/docker/overlay2/27af7557c9ad0419936dcaf240fc36616504f3aa35b76d5073d3319b838133d9/work"
},
"Name": "overlay2"
},
"Mounts": [
{
"Type": "bind",
"Source": "/var/run/docker.sock",
"Destination": "/var/run/docker.sock",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/Users/bhairav/.m2",
"Destination": "/root/.m2",
"Mode": "",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/sys/fs/cgroup",
"Destination": "/sys/fs/cgroup",
"Mode": "ro",
"RW": false,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/Users/bhairav/Applications/viptela/viptela-0309",
"Destination": "/viptela",
"Mode": "cached",
"RW": true,
"Propagation": "rprivate"
}
],
"Config": {
"Hostname": "vunit",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"2022/tcp": {},
"2024/tcp": {},
"4569/tcp": {}
},
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"HTTP_PROXY=http://proxy.esl.cisco.com:80",
"http_proxy=http://proxy.esl.cisco.com:80",
"NO_PROXY=cisco.com",
"no_proxy=cisco.com",
"PATH=/opt/nso/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"HTTPS_PROXY=http://proxy.esl.cisco.com:80",
"https_proxy=http://proxy.esl.cisco.com:80",
"TZ=America/Los_Angeles",
"TOOLS_HOME=/opt",
"NCS_VERSION=5.2.1.1",
"NCS_PKG=nso-5.2.1.1.linux.x86_64",
"NCS_LOCAL=/opt/nso",
"NCS_LOCAL_RUN=/opt/nso-run",
"NCS_CONF=/opt/nso-run/ncs.conf",
"NCS_DIR=/opt/nso",
"LD_LIBRARY_PATH=/opt/nso/lib:",
"PYTHONPATH=/opt/nso/src/ncs/pyapi",
"MANPATH=/opt/nso/man:/usr/share/man",
"SSHPASS=admin"
],
"Cmd": null,
"Image": "f2bda5208770",
"Volumes": null,
"WorkingDir": "/viptela",
"Entrypoint": [
"/usr/sbin/init"
],
"OnBuild": null,
"Labels": {
"Description": "vManage Unit Test Container",
"Maintainer": "vManage Engineering Team (vmanage-dev@cisco.com)",
"build-date": "20170911",
"license": "GPLv2",
"name": "CentOS Base Image",
"vendor": "CentOS"
},
"StopSignal": "SIGRTMIN+3"
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "6f47bb6a7a1172e0f1ea630cd4d2e3e90c4ee08346c33bbe578a82c53950cddc",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"2022/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "2022"
}
],
"2024/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "2024"
}
],
"4569/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "4569"
}
]
},
"SandboxKey": "/var/run/docker/netns/6f47bb6a7a11",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "810f2e069fdf3263856fd37f470e85a05dd081b26b668f8daab0e1c1eef9fcfe",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "5f3d42c57fe5dfb1f2f21ac74b35c0a2abbc7a146d6ea65056fa3feb25039bc8",
"EndpointID": "810f2e069fdf3263856fd37f470e85a05dd081b26b668f8daab0e1c1eef9fcfe",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
2 Replies 2

allenc
Level 1
Level 1

By default, NSO listens to 127.0.0.1:4569 for IPC connections. See this excerpt from the ncs.conf man page:

/ncs-config/ncs-ipc-address/ip (ipv4-address | ipv6-address) [127.0.0.1]
The IP address which NCS listens on for incoming connections from the Java library

/ncs-config/ncs-ipc-address/port (port-number) [4569]
The port number which NCS listens on for incoming connections from the Java library

Did you configure the ip to match what you expect to see from your port forwarding setup?

-Allen

 

Hi allen,

thank you for your response. Let me update ncs.conf and try it out

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: