# Can't do handshake when spark core connecting to my local spark server?

**URL:** <https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301>\
**Category:** Cloud\
**Created:** [April 16, 2015, 1:48am UTC](https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301 "2015-04-16T01:48:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![helxsz](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helxsz](https://community.particle.io/u/helxsz)\
**Post date:** [April 16, 2015, 1:48am UTC](https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301/1 "2015-04-16T01:48:27Z")

</div>

Today I tried to install the [spark-server](https://github.com/spark/spark-server) into my local mac, I followed the instruction from spark-server installation guide.

1. firstly i successfully loaded the local server public key and IP address into the core
2. in the second step, it asked to change the spark.config which is not found, so I tried the spark config command.  
**$ spark config local-spark  
$ spark config local apiUrl [http://localhost:8080](http://localhost:8080)**

I truly don't know what this step is for?

3, in the third step, I run **spark identify** to get my core id, this is ok  
4. in the last step, I tried the **spark setup** connecting the core to wifi, and core will also connect to the local server automatically, but the core is flashing the cyan fast, meaning can't connect the local server.

so I went to the server logs, found this error message

> Connection from: 192.168.43.223, connId: 30  
> 1: Core disconnected: read\_coreid timed out { coreID: 'unknown', cache\_key: '\_29' }  
> Session ended for \_29  
> Handshake failed: read\_coreid timed out { ip: '192.168.43.223', cache\_key: '\_29', coreID: null }

and

> Connection from: 192.168.43.223, connId: 1  
> Expected to find public key for core 51ff70065082554910410887 at /Users/abc/spark.io/spark-server/core\_keys/51ff70065082554910410887.pub.pem

The failed reason is because the core\_keys folder is empty with no keys at all. Is there any step I was doing wrong or missing, how to move the public key of the core into the server side?

The second question is as now my spark core stores the local server public key and IP address in the flash, if I want it to work with spark cloud again, how could I restore it back?

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [April 16, 2015, 2:01am UTC](https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301/2 "2015-04-16T02:01:20Z")

</div>

You might want to be more familiar with **Spark-cli** to know what is going on.

- `spark config local apiUrl http://localhost:8080`

This is creating a new **profile** for the ease of switching around different ☁

- `spark config identify`

This will print out the settings of the current profile for verification purposes so that you know you are pointing to the :cloud that you want to work with.

- `Expected to find public key`

You will need to place the core public key in that folder.

Might want to check this out: [https://community.spark.io/t/tutorial-local-cloud-1st-time-instructions-20-march-15/5589](https://community.spark.io/t/tutorial-local-cloud-1st-time-instructions-20-march-15/5589)

---

<div class="post-metadata">

**Author:** ![helxsz](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helxsz](https://community.particle.io/u/helxsz)\
**Post date:** [April 16, 2015, 2:55am UTC](https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301/3 "2015-04-16T02:55:32Z")

</div>

Thanks, @kennethlimcp, it works so good.

One question, if I am switching to the lcoal cloud, it means the over-the-air programming is disabled, right. Is there any other ways to compile and program the core in the local environment?

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [April 16, 2015, 4:07am UTC](https://community.particle.io/t/cant-do-handshake-when-spark-core-connecting-to-my-local-spark-server/11301/4 "2015-04-16T04:07:06Z")

</div>

OTA is working on local ☁, just not compiling

Try this:

`spark config spark; spark compile .; spark config local_profile; spark flash CORE_name *.bin`

This will switch to :spark: profile, compile using the :spark: build farm, switch over to your own ☁ and flash via OTA.

If you want a pure local compiling function, you will need to setup a toolchain to do so.
