# Mesh.publish() alloc errors and function/variable issues

**URL:** <https://community.particle.io/t/mesh-publish-alloc-errors-and-function-variable-issues/49027>\
**Category:** Troubleshooting\
**Tags:** xenon\
**Created:** [April 10, 2019, 3:24am UTC](https://community.particle.io/t/mesh-publish-alloc-errors-and-function-variable-issues/49027 "2019-04-10T03:24:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenmacd](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kenmacd/32/18154_2.png) [@kenmacd](https://community.particle.io/u/kenmacd)\
**Post date:** [April 10, 2019, 3:24am UTC](https://community.particle.io/t/mesh-publish-alloc-errors-and-function-variable-issues/49027/1 "2019-04-10T03:24:11Z")

</div>

When publishing messages with `Mesh.publish()` my xenons will stop responding to calls for the cloud, resulting in functions not working and OTA updates not working. `Particle.publish()` messages do seem to continue working.

The main error message seems to be:

```auto
[net.th] TRACE: input failed to alloc

```

I tested logging `System.freeMemory()` and there’s lots of normal memory available.

Example program:

```auto
SerialLogHandler logHandler(LOG_LEVEL_ALL);

void setup() {
}

void loop() {
  system_tick_t now = millis();
  if (Mesh.ready()) {
    Mesh.publish("Testing");
  }
  delay(250);
}

```

It also seems to result in the connection to the cloud server being rebuilt often:

```auto
0000123486 [net.th] TRACE: input failed to alloc
0000128861 [net.th] TRACE: input failed to alloc
0000134233 [net.th] TRACE: input failed to alloc
0000134493 [comm.protocol] ERROR: Event loop error 1
0000134494 [system] WARN: Communication loop error, closing cloud socket
0000134496 [system] INFO: Cloud: disconnecting
0000134498 [system] INFO: Cloud: disconnected
0000134750 [system] INFO: Cloud: connecting
0000134753 [system] INFO: Read Server Address = type:1,domain:$id.udp-mesh.particle.io
0000134755 [system] INFO: Loaded cloud server address and port from session data
0000134758 [system] TRACE: Address type: 1
0000134759 [system] TRACE: Cloud socket=0, family=10, type=2, protocol=17
0000134761 [system] INFO: Cloud socket=0, connecting to 64:FF9B::36A6:B5BF#5684
0000134763 [system] TRACE: Cloud socket=0, connected to 64:FF9B::36A6:B5BF#5684
0000134765 [system] TRACE: Updating cloud keepalive for AF_INET6: 30000 -> 30000
0000134768 [system] TRACE: Applying new keepalive interval now
0000134769 [system] INFO: Cloud socket connected
0000134771 [system] INFO: Starting handshake: presense_announce=0
0000134772 [comm.protocol.handshake] INFO: Establish secure connection
0000134972 [comm.dtls] INFO: (CMPL,RENEG,NO_SESS,ERR) restoreStatus=0
0000134974 [comm.dtls] INFO: out_ctr 0,1,0,0,0,0,1,66, next_coap_id=12d
0000134975 [comm.dtls] INFO: app state crc: cached: 5eb2b659, actual: 5eb2b659
0000134978 [comm.dtls] WARN: skipping hello message
0000134979 [comm.dtls] INFO: restored session from persisted session data. next_msg_id=301
0000134981 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 2
0000134983 [comm.protocol.handshake] INFO: resumed session - not sending HELLO message
0000134989 [system] INFO: Send spark/hardware/max_binary event
0000134991 [system] INFO: Send subscriptions
0000134995 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 4
0000134997 [comm.dtls] INFO: session cmd (CLS,DIS,MOV,LOD,SAV): 3
0000134999 [comm] INFO: Sending TIME request
0000135002 [system] INFO: Cloud connected

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![armor](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/armor/32/18398_2.png) [@armor](https://community.particle.io/u/armor)\
**Post date:** [April 10, 2019, 8:29pm UTC](https://community.particle.io/t/mesh-publish-alloc-errors-and-function-variable-issues/49027/2 "2019-04-10T20:29:57Z")

</div>

The Mesh.publish() call syntax is

> // SYNTAX  
> Mesh.publish(const char \*name, const char \*data);

You appear to be missing the event name or event data?

---

<div class="post-metadata">

**Author:** ![kenmacd](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/kenmacd/32/18154_2.png) [@kenmacd](https://community.particle.io/u/kenmacd)\
**Post date:** [April 10, 2019, 8:51pm UTC](https://community.particle.io/t/mesh-publish-alloc-errors-and-function-variable-issues/49027/3 "2019-04-10T20:51:32Z")

</div>

Hi @armor, thanks for the suggestion. I was originally seeing this issue with data included, I just removed it to make the test as simple as possible.

I double checked it and I think `data` shouldn't be required. The docs include:

> optional data (up to 255 bytes)

and [the source](https://github.com/particle-iot/device-os/blob/develop/wiring/inc/spark_wiring_mesh.h#L129) does seem to include a default value:

> int publish(const char\* topic, const char\* data = nullptr);
