TCP connection to private server (spark core as tcp client)

python server.py
Connection address: (‘192.168.1.104’, 2236)
received data: connected
received data:
received data:

On Serial port

Pinging 5 times: 5
connecting…
connected
-1
disconnecting.

192.168.1.104 on RedPenguin
Pinging 5 times: 5
connecting…
connected
-1

disconnecting.
192.168.1.104 on

You are not calling client.available() so you don’t know if there is any data there yet. client.read() returns -1 to indicate there is no data to read.

makes sense. I think the last issue which needs to be somehow resolved is why does it fails to connect after two success attempts. As soon as I restart the listener the first two attempts from Core work and then I have to restart the listener again to get more data which shouldn’t be the case. Any insights?

python server.py
Connection address: (‘192.168.1.104’, 2118)
received data: connected
received data:
received data:
— Serial port debug
92.168.1.104 on RedPenguin
Pinging 5 times: 5
connecting…
connected

disconnecting.
192.168.1.104 on RedPenguin
Pinging 5 times: 5
connecting…
connected

disconnecting.
192.168.1.104 on RedPenguin
Pinging 5 times: 5
connecting…
connection failed

disconnecting.
192.168.1.104 on RedPenguin
Pinging 5 times: 5
connecting…
connection failed

If you are not calling client.stop() then client.connect() is getting a new socket every time from the TI CC3000 WiFi chip and there are only 8 total sockets. Either leave the connection open and don’t call connect every time or call client.stop() when you are done and re-connect when you need to.

1 Like

I am very convinced either the wifi on core has a issue or my build needs an update. Do I need “deep_update”?

SPARK FIRMWARE V0.2.3 (JUNE 17) CHANGELOG
core-firmware e280c5
core-communication-lib aef1c7
core-common-lib 13427d

The Core network is really flaky for me and if everything looks good then I think it is worth for me to return this and buy a wifi module for Arduino because I have spent lots of time working with this and it works sometimes and sometimes it doesn’t which is very frustrating…

is there a way I can get a spare core to test as I have tested this core on multiple networks (mine and a friend of mines) and it gives same issues on both networks

My Server is 192.168.1.110 and gateway is 192.168.1.1
108 is Core
113 is Another Windows Server.

Please see below: I am unable to trace route to Core or ping core while no issues with the other windows server and other devices on that network. This happens intermittently. Please let me know if there is a solution or should I simply move on to using some other device instead of Spark core. thanks

ping 192.168.1.108
PING 192.168.1.108 (192.168.1.108): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
^C
— 192.168.1.108 ping statistics —
8 packets transmitted, 0 packets received, 100.0% packet loss
MBP-Lkhosla:~ lkohsla$ ping 192.168.1.113
PING 192.168.1.113 (192.168.1.113): 56 data bytes
64 bytes from 192.168.1.113: icmp_seq=0 ttl=128 time=4.003 ms
64 bytes from 192.168.1.113: icmp_seq=1 ttl=128 time=1.648 ms
64 bytes from 192.168.1.113: icmp_seq=2 ttl=128 time=3.947 ms
64 bytes from 192.168.1.113: icmp_seq=3 ttl=128 time=2.152 ms
64 bytes from 192.168.1.113: icmp_seq=4 ttl=128 time=1.748 ms
64 bytes from 192.168.1.113: icmp_seq=5 ttl=128 time=2.174 ms
^C
— 192.168.1.113 ping statistics —
6 packets transmitted, 6 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.648/2.612/4.003/0.983 ms
MBP-Lkhosla:~ lkohsla$ traceroute 192.168.1.113
traceroute to 192.168.1.113 (192.168.1.113), 64 hops max, 52 byte packets
1 192.168.1.113 (192.168.1.113) 3.868 ms 1.339 ms 1.300 ms
MBP-Lkhosla:~ lkohsla$ traceroute 192.168.1.108

traceroute to 192.168.1.108 (192.168.1.108), 64 hops max, 52 byte packets
1 * * *
2 * * *
3 *

A simple flash of code and reboot of core, after that I loose the route to the core or ability to even ping it.
112 is core

64 bytes from 192.168.1.112: icmp_seq=110 ttl=64 time=4.512 ms
64 bytes from 192.168.1.112: icmp_seq=111 ttl=64 time=3.461 ms
64 bytes from 192.168.1.112: icmp_seq=112 ttl=64 time=4.953 ms
64 bytes from 192.168.1.112: icmp_seq=113 ttl=64 time=3.890 ms
64 bytes from 192.168.1.112: icmp_seq=114 ttl=64 time=3.680 ms
64 bytes from 192.168.1.112: icmp_seq=115 ttl=64 time=8.808 ms
64 bytes from 192.168.1.112: icmp_seq=116 ttl=64 time=5.289 ms
64 bytes from 192.168.1.112: icmp_seq=117 ttl=64 time=4.716 ms
64 bytes from 192.168.1.112: icmp_seq=118 ttl=64 time=4.131 ms
64 bytes from 192.168.1.112: icmp_seq=119 ttl=64 time=4.439 ms
64 bytes from 192.168.1.112: icmp_seq=120 ttl=64 time=4.135 ms
64 bytes from 192.168.1.112: icmp_seq=121 ttl=64 time=4.184 ms
64 bytes from 192.168.1.112: icmp_seq=122 ttl=64 time=4.472 ms
64 bytes from 192.168.1.112: icmp_seq=123 ttl=64 time=4.677 ms
64 bytes from 192.168.1.112: icmp_seq=124 ttl=64 time=4.711 ms
64 bytes from 192.168.1.112: icmp_seq=125 ttl=64 time=4.684 ms
64 bytes from 192.168.1.112: icmp_seq=126 ttl=64 time=4.432 ms
64 bytes from 192.168.1.112: icmp_seq=127 ttl=64 time=4.130 ms
64 bytes from 192.168.1.112: icmp_seq=128 ttl=64 time=4.619 ms
64 bytes from 192.168.1.112: icmp_seq=129 ttl=64 time=4.461 ms
64 bytes from 192.168.1.112: icmp_seq=130 ttl=64 time=4.701 ms
64 bytes from 192.168.1.112: icmp_seq=131 ttl=64 time=4.791 ms
64 bytes from 192.168.1.112: icmp_seq=132 ttl=64 time=4.348 ms
64 bytes from 192.168.1.112: icmp_seq=133 ttl=64 time=4.071 ms
64 bytes from 192.168.1.112: icmp_seq=134 ttl=64 time=4.529 ms
64 bytes from 192.168.1.112: icmp_seq=135 ttl=64 time=4.898 ms
64 bytes from 192.168.1.112: icmp_seq=136 ttl=64 time=4.449 ms
64 bytes from 192.168.1.112: icmp_seq=137 ttl=64 time=7.073 ms
64 bytes from 192.168.1.112: icmp_seq=138 ttl=64 time=3.416 ms
64 bytes from 192.168.1.112: icmp_seq=139 ttl=64 time=3.510 ms
64 bytes from 192.168.1.112: icmp_seq=140 ttl=64 time=4.754 ms
64 bytes from 192.168.1.112: icmp_seq=141 ttl=64 time=4.003 ms
64 bytes from 192.168.1.112: icmp_seq=142 ttl=64 time=4.390 ms
64 bytes from 192.168.1.112: icmp_seq=143 ttl=64 time=4.123 ms
64 bytes from 192.168.1.112: icmp_seq=144 ttl=64 time=3.934 ms
64 bytes from 192.168.1.112: icmp_seq=145 ttl=64 time=4.240 ms
64 bytes from 192.168.1.112: icmp_seq=146 ttl=64 time=7.650 ms
64 bytes from 192.168.1.112: icmp_seq=147 ttl=64 time=4.147 ms
64 bytes from 192.168.1.112: icmp_seq=148 ttl=64 time=4.144 ms
64 bytes from 192.168.1.112: icmp_seq=149 ttl=64 time=4.649 ms
64 bytes from 192.168.1.112: icmp_seq=150 ttl=64 time=4.646 ms
64 bytes from 192.168.1.112: icmp_seq=151 ttl=64 time=4.733 ms
64 bytes from 192.168.1.112: icmp_seq=152 ttl=64 time=4.765 ms
64 bytes from 192.168.1.112: icmp_seq=153 ttl=64 time=4.190 ms
64 bytes from 192.168.1.112: icmp_seq=154 ttl=64 time=4.229 ms
64 bytes from 192.168.1.112: icmp_seq=155 ttl=64 time=9.280 ms
64 bytes from 192.168.1.112: icmp_seq=156 ttl=64 time=4.058 ms
64 bytes from 192.168.1.112: icmp_seq=157 ttl=64 time=4.835 ms
64 bytes from 192.168.1.112: icmp_seq=158 ttl=64 time=4.189 ms
64 bytes from 192.168.1.112: icmp_seq=159 ttl=64 time=4.044 ms
64 bytes from 192.168.1.112: icmp_seq=160 ttl=64 time=3.630 ms
64 bytes from 192.168.1.112: icmp_seq=161 ttl=64 time=4.688 ms
64 bytes from 192.168.1.112: icmp_seq=162 ttl=64 time=4.680 ms
64 bytes from 192.168.1.112: icmp_seq=163 ttl=64 time=4.984 ms
64 bytes from 192.168.1.112: icmp_seq=164 ttl=64 time=4.786 ms
64 bytes from 192.168.1.112: icmp_seq=165 ttl=64 time=3.503 ms
64 bytes from 192.168.1.112: icmp_seq=166 ttl=64 time=4.678 ms

Flash New Code

— 192.168.1.112 ping statistics —
167 packets transmitted, 57 packets received, 65.9% packet loss
round-trip min/avg/max/stddev = 3.416/4.634/9.280/1.088 ms
MBP-Lkhosla:~ lkohsla$ ping 192.168.1.112
PING 192.168.1.112 (192.168.1.112): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
Request timeout for icmp_seq 13
Request timeout for icmp_seq 14
Request timeout for icmp_seq 15
Request timeout for icmp_seq 16
Request timeout for icmp_seq 17
Request timeout for icmp_seq 18
Request timeout for icmp_seq 19
Request timeout for icmp_seq 20
Request timeout for icmp_seq 21

Hi @lkhosla

One of the side effects of deep update for the TI CC3000 is that it no longer answers ping’s autonomously–I think TI must have run out of code space in the WiFi chip. Don’t be alarmed that you cannot ping your core. You can’t ping Amazon AWS or EC2 hosts either but it doesn’t stop them from being useful.

I think you should consider switching over to a HTML library for your connection–it will have all the issues you are running into worked out. Lots of folks have used this one:

but there are other choices including a JSON based library.

1 Like

Thanks, Any documentation available for JSON library and also WIFI?

Here is what I am trying to achieve. Maybe you can guide me how to achieve it

  1. I have a MySQL DB on a server
  2. I have Spark core (powered over battery)
  3. I want to send the data from core to MySQL server which is on the same WiFi network as spark core
  4. Once I get the data , I can load it into MySQL DB.

Please point me towards a documentation or guide me a bit and I can take it from there.

1 Like

This post is old so you might have already found your answer?
If not - my example does everything in your list :

@bko is there a way to read how many sockets are currently in use ?

Well I found a way but you need to be careful with it!

    for(int i=0; i<7;i++) {
        int status = get_socket_active_status(i);
        Serial.print(status);   //0 means in use, 1 means free   
    }

There might be an easier way but this was quick and dirty.

2 Likes

@ufo567 Try formatting your pasted code in Markdown

```<your language>
//paste your code here

Not sure if this forum supports GHML.