# Got a error for first-service-sdk-plain

**URL:** <https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601>\
**Category:** SDK Questions\
**Created:** [May 22, 2024, 9:10am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601 "2024-05-22T09:10:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 22, 2024, 9:10am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/1 "2024-05-22T09:10:36Z")

</div>

When I was conducting the experiment at [ziti/ziti/cmd/demo/tutorials/first-service.md at release-next · openziti/ziti · GitHub](https://github.com/openziti/ziti/blob/release-next/ziti/cmd/demo/tutorials/first-service.md), I encountered a problem. First, a service and a terminator were created on the server side, and then on the client side, I executed `ziti demo ziti-echo-client --identity /home/ubuntu/founder-laptop.json trees are tall` , but I got the error "The connection to the server echo was refused - did you specify the right host or port?"  
The server steps like follows：  
0、ziti edge login  
1、ziti edge create service echo  
2、ziti demo plain-echo-server --port 62239 \> /dev/null 2\>&1 &  
3、ziti demo plain-echo-client --port 62239 trees are tall //the result does not has any problem  
4、ziti edge create terminator echo {{ controller\_hostname }}-edge-router tcp:localhost:62239

The Client steps like follows：  
0、ziti edge login  
1、ziti edge create identity user founder-laptop -o founder-laptop.jwt --role-attributes management  
2、ziti edge enroll -j founder-laptop.jwt -o founder-laptop.json  
3、ziti edge create service-policy echo-clients Dial --service-roles '@echo' --identity-roles '#management'  
4、ziti edge create edge-router-policy echo-clients --edge-router-roles '@{{ controller\_hostname }}-edge-router' --identity-roles '#management'  
5、ziti edge create service-edge-router-policy echo --edge-router-roles '#all' --service-roles '@echo'  
6、ziti demo ziti-echo-client --identity founder-laptop.json trees are tall

When I executed to the sixth step on the client side, I encountered the error "The connection to the server echo was refused - did you specify the right host or port?"

 ![1](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/4/46b814ca074125b1a02825781af4243722289c2f.png)  
 ![2](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/f/f80379678ca6ad8a854d2a68c2d282a29cb7c394.png)  
 ![3](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/3/335c2e3e9bb7c1d9057ae6a2e3515ae89df8b28e.png)  
 ![4](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/6/60db2c8ccd62d803df950f51a04dbb9ce4154af3.png)  
 ![4](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/6/60db2c8ccd62d803df950f51a04dbb9ce4154af3.png)

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 22, 2024, 5:04pm UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/2 "2024-05-22T17:04:59Z")

</div>

Hi @rootwang

I think you're confusing two different things. The server you are running is listening on the underlay network. To access it with your server example, on the client you would run:

```auto
ziti demo plain-echo-client --port 62239

```

As you have shown it, you're using the "application embedded" example. For that, you need to start the server differently and use the `ziti-echo-server`:

```auto
ziti demo ziti-echo-server --identity echo-server.json

```

plain --\> ziti ... an easy thing to get wrong!

If you start the ziti-echo-server, it should work for you

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 23, 2024, 2:01am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/3 "2024-05-23T02:01:14Z")

</div>

> [@TheLumberjack](#):
>
> `ziti demo ziti-echo-server`

Thank you for your reply, I run with "ziti demo first-service" and follow this step by step.  
as you said, i start plain-echo-server on server, and then start plain-echo-client on client like  
"ziti demo plain-echo-client --host ${server\_public\_ip} --port 62239 trees are tall ",but got i/o timeout.  
Actually I have successfully executed `ziti demo ziti-echo-server` using the bind way, But actually, I wanted to test how to successfully connect from the client side using a terminator that I created myself.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 23, 2024, 12:13pm UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/4 "2024-05-23T12:13:21Z")

</div>

> [@rootwang](#):
>
> I wanted to test how to successfully connect from the client side using a terminator that I created myself.

Oh. My misunderstanding! I assume you're just trying to learn more? I don't create terminators manually, myself. I much prefer to use the "tunneling" features of a router instead and assign the router's identity the ability to bind the service (allowing the router/controller to create the terminator automatically). I haven't actually created a terminator manually in a long, long time. 🙂 I'll try to go through the readme again and make sure the doc is accurate and follow-up.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 23, 2024, 12:58pm UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/5 "2024-05-23T12:58:00Z")

</div>

Ok, after running through it a couple times, i suspect you're just not setting the port variable properly after starting the server. The underlay listening port started by the server is changing every time you run it...

After starting the server with:

```auto
ziti demo plain-echo-server

```

in a separate window, whatever the port is you should use. Here's a full gif showing all the steps:  
 ![terminator](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/2X/b/b69be47e291934e0526ecac98bfebaa54ff03325.gif)

And if helpful, here's every single command I ran on that bottom screen :

```auto
port=
ziti edge list ers
edgeRouterName="

ziti edge create terminator echo ${edgeRouterName} tcp:localhost:${port}
ziti demo plain-echo-client --port ${port} trees are tall
ziti edge create identity user founder-laptop -o founder-laptop.jwt --role-attributes management
ziti edge list identities 'name="founder-laptop"'
ziti edge enroll -j founder-laptop.jwt -o founder-laptop.json
ziti demo ziti-echo-client --identity founder-laptop.json trees are tall

ziti edge policy-advisor identities -q founder-laptop echo
ziti edge create service-policy echo-clients Dial --service-roles '@echo' --identity-roles '#management'
ziti edge list service-policies 'name="echo-clients"'
ziti edge policy-advisor identities -q founder-laptop echo
ziti demo ziti-echo-client --identity founder-laptop.json trees are tall

```

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 24, 2024, 1:30am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/6 "2024-05-24T01:30:39Z")

</div>

Thank you for your thorough and patient replies. I don't think the issue is with the port variable properly, as I specified the port when running the command with  
"ziti demo plain-echo-client --port 62239".  
I noticed that your server and client are running on the same machine. I was wondering if you could try running the server and client on two different machines.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 24, 2024, 1:38am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/7 "2024-05-24T01:38:00Z")

</div>

Oh. Interesting. You're running the server and router on the same server, correct? I can setup a test where I run on two different machines, sure. I'll give it a try

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 24, 2024, 1:57am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/8 "2024-05-24T01:57:46Z")

</div>

Actually, I have set up three machines，the controller and edge router are running on one machine, while the client and server are running on the other two separate machines.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 24, 2024, 2:02am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/9 "2024-05-24T02:02:22Z")

</div>

Oh, and you make the Terminator with this?

```auto
4、ziti edge create terminator echo {{ controller_hostname }}-edge-router tcp:localhost:62239

```

I'd think you need to change that localhost to whatever the machine name is that runs the service.

That command instructs the router where to offload data towards. So you probably want that to be

```auto
tcp: address-of-the-running-the-server:62239

```

That seems like it's probably the issue

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 24, 2024, 2:19am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/11 "2024-05-24T02:19:12Z")

</div>

ok，I'll give it a try

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 24, 2024, 5:50am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/12 "2024-05-24T05:50:02Z")

</div>

I tried it, but is not work. Here is whole execution processes. I'm wondering if you could take some time to help me figure out where the issue is. Thank you.

```auto
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge login ${controller_pub_ip}:8441 -u admin -p admin -y
Token: 6acd981a-56a2-46e6-8ccb-7213004d1c42
Saving identity 'default' to /home/ubuntu/.config/ziti/ziti-cli.json
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list ers
╭────────────┬──────────────────────────┬────────┬───────────────┬──────┬────────────╮
│ ID │ NAME │ ONLINE │ ALLOW TRANSIT │ COST │ ATTRIBUTES │
├────────────┼──────────────────────────┼────────┼───────────────┼──────┼────────────┤
│ EzVALXXC.c │ ip-10-1-2-34-edge-router │ true │ true │ 0 │ public │
╰────────────┴──────────────────────────┴────────┴───────────────┴──────┴────────────╯
results: 1-1 of 1
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create service echo
New service echo created with id: F53Ou5YPAHp2uJZRA6qyu
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti demo plain-echo-server --port 62239 > /home/ubuntu/echo.log 2>&1 &

ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create terminator echo ip-10-1-2-34-edge-router tcp:localhost:62239
New terminator created with id: 3nlxPIlE4w5BRlIvnZMHBB
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create identity user founder-laptop -o /home/ubuntu/founder-laptop.jwt --role-attributes management
Command "user" is deprecated, this command is deprecated, specifying identity type is no longer required
New identity founder-laptop created with id: tzwsVwB5j
Enrollment expires at 2024-05-24T08:05:19.343Z
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge enroll -j /home/ubuntu/founder-laptop.jwt -o /home/ubuntu/founder-laptop.json
INFO generating 4096 bit RSA key
INFO enrolled successfully. identity file written to: /home/ubuntu/founder-laptop.json
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create service-policy echo-clients Dial --service-roles '@echo' --identity-roles '#management'
New service policy echo-clients created with id: UCBk7bWrhnDDMaIeSqzue
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create edge-router-policy echo-clients --edge-router-roles '@ip-10-1-2-34-edge-router' --identity-roles '#management'
New edge router policy echo-clients created with id: urSukPDrcHuuGw9fW38YQ
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create service-edge-router-policy echo --edge-router-roles '#all' --service-roles '@echo'
New service edge router policy echo created with id: 5NAPT70gJ9C1j1UVOO0KUp

ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti demo ziti-echo-client --identity /home/ubuntu/founder-laptop.json trees are tall
The connection to the server echo was refused - did you specify the right host or port?
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list terminators
╭────────────────────────┬─────────┬──────────────────────────┬────────────────┬─────────────────────┬──────────┬──────┬────────────┬──────────────╮
│ ID │ SERVICE │ ROUTER │ BINDING │ ADDRESS │ IDENTITY │ COST │ PRECEDENCE │ DYNAMIC COST │
├────────────────────────┼─────────┼──────────────────────────┼────────────────┼─────────────────────┼──────────┼──────┼────────────┼──────────────┤
│ 3nlxPIlE4w5BRlIvnZMHBB │ echo │ ip-10-1-2-34-edge-router │ edge_transport │ tcp:localhost:62239 │ │ 0 │ default │ 20 │
╰────────────────────────┴─────────┴──────────────────────────┴────────────────┴─────────────────────┴──────────┴──────┴────────────┴──────────────╯
results: 1-1 of 1
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ lsof -i:62239
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
ziti 1711 ubuntu 3u IPv4 23752 0t0 TCP localhost:62239 (LISTEN)

ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge delete terminator 3nlxPIlE4w5BRlIvnZMHBB
delete of terminator with id 3nlxPIlE4w5BRlIvnZMHBB: OK
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create terminator echo ip-10-1-2-34-edge-router tcp:10.3.1.188:62239
New terminator created with id: 4y5qQ9ZEYzJeygSF3WkR1A
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti demo ziti-echo-client --identity /home/ubuntu/founder-laptop.json hello world
[5.174] ERROR sdk-golang/ziti/edge/network.(*edgeConn).Connect: {sessionId=[0xc0004f9f20] marker=[eyMEhwRw] connId=[1]} timeout waiting for message reply: context deadline exceeded
Unable to connect to the server: unable to dial service 'echo': timeout waiting for message reply: context deadline exceeded
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list services
╭───────────────────────┬──────┬────────────┬─────────────────────┬────────────╮
│ ID │ NAME │ ENCRYPTION │ TERMINATOR STRATEGY │ ATTRIBUTES │
│ │ │ REQUIRED │ │ │
├───────────────────────┼──────┼────────────┼─────────────────────┼────────────┤
│ F53Ou5YPAHp2uJZRA6qyu │ echo │ true │ smartrouting │ │
╰───────────────────────┴──────┴────────────┴─────────────────────┴────────────╯
results: 1-1 of 1
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list service-policy services echo-clients
╭───────────────────────┬──────┬────────────┬─────────────────────┬────────────╮
│ ID │ NAME │ ENCRYPTION │ TERMINATOR STRATEGY │ ATTRIBUTES │
│ │ │ REQUIRED │ │ │
├───────────────────────┼──────┼────────────┼─────────────────────┼────────────┤
│ F53Ou5YPAHp2uJZRA6qyu │ echo │ true │ smartrouting │ │
╰───────────────────────┴──────┴────────────┴─────────────────────┴────────────╯
results: 1-1 of 1
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list terminators
╭────────────────────────┬─────────┬──────────────────────────┬────────────────┬──────────────────────┬──────────┬──────┬────────────┬──────────────╮
│ ID │ SERVICE │ ROUTER │ BINDING │ ADDRESS │ IDENTITY │ COST │ PRECEDENCE │ DYNAMIC COST │
├────────────────────────┼─────────┼──────────────────────────┼────────────────┼──────────────────────┼──────────┼──────┼────────────┼──────────────┤
│ 4y5qQ9ZEYzJeygSF3WkR1A │ echo │ ip-10-1-2-34-edge-router │ edge_transport │ tcp:10.3.1.188:62239 │ │ 0 │ default │ 55 │
╰────────────────────────┴─────────┴──────────────────────────┴────────────────┴──────────────────────┴──────────┴──────┴────────────┴──────────────╯
results: 1-1 of 1
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge delete terminator 4y5qQ9ZEYzJeygSF3WkR1A
delete of terminator with id 4y5qQ9ZEYzJeygSF3WkR1A: OK
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge create terminator echo ip-10-1-2-34-edge-router tcp:3.123.20.232:62239
New terminator created with id: 453HjQnISeXMLeERk3Hmta
ubuntu@ip-10-3-1-188:~$
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti demo ziti-echo-client --identity /home/ubuntu/founder-laptop.json hello world
[5.171] ERROR sdk-golang/ziti/edge/network.(*edgeConn).Connect: {marker=[zPNTBCcb] connId=[1] sessionId=[0xc0004f9f90]} timeout waiting for message reply: context deadline exceeded
Unable to connect to the server: unable to dial service 'echo': timeout waiting for message reply: context deadline exceeded
ubuntu@ip-10-3-1-188:~$ /home/ubuntu/ziti edge list terminators
╭────────────────────────┬─────────┬──────────────────────────┬────────────────┬────────────────────────┬──────────┬──────┬────────────┬──────────────╮
│ ID │ SERVICE │ ROUTER │ BINDING │ ADDRESS │ IDENTITY │ COST │ PRECEDENCE │ DYNAMIC COST │
├────────────────────────┼─────────┼──────────────────────────┼────────────────┼────────────────────────┼──────────┼──────┼────────────┼──────────────┤
│ 453HjQnISeXMLeERk3Hmta │ echo │ ip-10-1-2-34-edge-router │ edge_transport │ tcp:3.123.20.232:62239 │ │ 0 │ default │ 0 │
╰────────────────────────┴─────────┴──────────────────────────┴────────────────┴────────────────────────┴──────────┴──────┴────────────┴──────────────╯
results: 1-1 of 1

```

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 24, 2024, 7:26am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/13 "2024-05-24T07:26:10Z")

</div>

I just successful run it on the machine where the controller and edge router installed, but still not work on the client or server side. I do not understand what the difference between them.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 24, 2024, 9:43am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/14 "2024-05-24T09:43:43Z")

</div>

Ok. I'll give it a try in a couple hours and post back my findings

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 24, 2024, 1:47pm UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/15 "2024-05-24T13:47:40Z")

</div>

### You can't use three machines...

I set up my whole environment and then started the server and remembered something else I'd forgotten and lost along the way. That server exclusively listens on `127.0.0.1`. This means you **MUST** run the server on the same machine as the router, or you need to build the [ziti executable with this line set to `0.0.0.0`](https://github.com/openziti/ziti/blob/release-next/ziti/cmd/demo/plain_echo_server.go#L43) (or whatever IP) for it to work

You **can** use two different computers, but you **MUST** run the server on the machine the router is on due to how the code is written.

### Dunno how this worked...

I don't know how this command could have worked for you:

> ziti demo plain-echo-client --port 62239 trees are tall //the result does not has any problem

On my machine, I get:

> $ ziti demo plain-echo-client --port 62239 trees are tall //the result does not has any problem  
> [0.001] INFO ziti/ziti/cmd/helpers.StandardErrorMessage: Connection error: Get [http://localhost:62239?input=trees+are+tall+%2F%2Fthe+result+does+not+has+any+problem:](http://localhost:62239?input=trees+are+tall+%2F%2Fthe+result+does+not+has+any+problem:) dial tcp 127.0.0.1:62239: connect: connection refused  
> The connection to the server localhost:62239 was refused - did you specify the right host or port?

### MINIMAL steps to use TWO computers

#### Computer 1 -- Where the router is - run the server

```auto
port=62239
ziti demo plain-echo-server --port $port

```

#### Computer 2 -- some other machine -- configure then run the client

Clean everything up:

```auto
ziti edge delete service echo
ziti edge delete identities founder-laptop echo-server
ziti edge delete service-policies where true
ziti edge delete edge-router-policies where 'isSystem = false'
ziti edge delete service-edge-router-policies where true

```

Run/Configure things

```auto
port=62239
edgeRouterName="ip-172-31-47-200-edge-router"

ziti edge create service echo
ziti edge create identity user founder-laptop -o founder-laptop.jwt --role-attributes management
ziti edge enroll -j founder-laptop.jwt -o founder-laptop.json

ziti edge create terminator echo ${edgeRouterName} tcp:localhost:${port}
ziti edge create service-policy echo-clients Dial --service-roles '@echo' --identity-roles '#management'

ziti edge create edge-router-policy echo-clients --edge-router-roles "@${edgeRouterName}" --identity-roles '#management'
ziti edge create service-edge-router-policy echo --edge-router-roles '#all' --service-roles '@echo'
ziti demo ziti-echo-client --identity founder-laptop.json trees are tall

```

Hope this clears everything up! 🙂

### ADDENDUM - EDIT:

You could always spin up a python server somewhere (or whatever) and use that you just can't use the example server.

```auto
$ python3 -m http.server
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ...

```

notice it listens on 0.0.0.0 not 127.0.0.1

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 27, 2024, 3:21am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/16 "2024-05-27T03:21:16Z")

</div>

Please excuse me for getting back to you so late, i think you are right, and i ran this command on the server too, it worked. this two command run on the same machine.

```auto
ziti demo plain-echo-server --port 62239 > /dev/null 2>&1 &
ziti demo plain-echo-client --port 62239 trees are tall

```

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 27, 2024, 2:34pm UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/17 "2024-05-27T14:34:07Z")

</div>

I think you're all set now, right? I am assuming you're moving on, but if you're still stuck somehow lemme know. Cheers

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 28, 2024, 1:48am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/18 "2024-05-28T01:48:00Z")

</div>

Yes, I have already figured it out as you suggested. It indeed took me a long long time 🤣, but finally i understood the relationship between service, terminator, and server. Thank you for your patient and good help again.

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 29, 2024, 12:57am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/19 "2024-05-29T00:57:56Z")

</div>

Sorry to brother you again, i still encounted the same problem in the second way with a little difference from yours.

#### Computer 1 -- Run the edge router and controller

#### Computer 2 -- Run the server

#### Computer 3 -- configure then run the client

At first, I modified some codes that your mentioned and `go build` it.  
The codes is

```auto
bindAddr := fmt.Sprintf("127.0.0.1:%v", s.Port)
s.listener, err = net.Listen("tcp", bindAddr)

```

changed to

```auto
bindAddr := fmt.Sprintf("0.0.0.0:%v", s.Port)
s.listener, err = net.Listen("tcp4", bindAddr)

```

then run the server

```auto
port=62239
ziti demo plain-echo-server --port $port

```

log is

```auto
plain-http-echo-server: listening on 0.0.0.0:62239

```

and then run the client

```auto
....
....
ubuntu@ip-10-2-1-27:~$ ./ziti demo ziti-echo-client --identity /home/ubuntu/founder-laptop.json trees are tall
The connection to the server echo was refused - did you specify the right host or port?

```

the other commands is same with you, so I didn't include them.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [May 29, 2024, 1:02am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/20 "2024-05-29T01:02:03Z")

</div>

You kept all the commands identical to what I posted? for example, you ran this exact command?

```auto
ziti edge create terminator echo ${edgeRouterName} tcp:localhost:${port}

```

IF that's the case, the `localhost` is the issue... You should:

1. make sure the router can access the server you started - it won't be `localhost:${port}`, it'll be something else.
2. Assuming the router can use curl or wget to access the server, then update the `create terminator` command and use the correct IP/Hostname and port

---

<div class="post-metadata">

**Author:** ![rootwang](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/rootwang/32/2134_2.png) [@rootwang](https://openziti.discourse.group/u/rootwang)\
**Post date:** [May 29, 2024, 7:17am UTC](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601/21 "2024-05-29T07:17:05Z")

</div>

I changed "localhost:${port}" to "${server\_pub\_ip}:${port}", it worked. thank you.  
I list the differences between bind and create terminator by manual

**bind** ：

```auto
1. create a identity to bind the service
2. ziti edge create service-policy echo-bind Bind ...

```

**create terminator by manual**

```auto
1. no need to create an identity
2. ziti edge create terminator
3. for example：ziti edge create edge-router-policy ssh-clients --edge-router-roles "@#{edge-router-name}" --identity-roles '#clients'
4. the edge route need to access the server

```

I remembered you mentioned that the bind way is more commonly used, but I found created by manual more convenient for management. I would like to ask, what are the differences in their usage scenarios In your opinion?

[Next page](https://openziti.discourse.group/t/got-a-error-for-first-service-sdk-plain/2601.md?page=2)
