AWS Builder Center
The Earthquake Early Warnings My App Sent Weren't Real EEWs

The Earthquake Early Warnings My App Sent Weren't Real EEWs

I traced a flood of false Earthquake Early Warning alerts to a misread API field, and found the real code buried in the spec.

Series: Earthquake Alert (3 articles)

  1. 2
    The Earthquake Early Warnings My App Sent Weren't Real EEWs This article
Cloud Engineer
In my last post, I wrote about building a text-based earthquake alert PWA for Japan — shindo 1+ shown, shindo 5-weak+ and Earthquake Early Warnings (EEW) shown with emphasis and a highlighted map. I shipped it, kept running it, and after a while noticed something off: "Earthquake Early Warning Detected" notifications were arriving roughly every one to two minutes.
Japan's Meteorological Agency does not issue EEWs that often. Something was wrong, and tracking it down turned into the most useful debugging session of the whole project.

What was actually happening

The app listens to P2P Earthquake Information's WebSocket feed, where each message carries a numeric  code  identifying its type. I had treated codes 554 and 555 as "EEW detected" and "EEW warning" respectively. In the first post I already mentioned that 555's  areas  field turned out to be P2P network peer counts rather than municipality-level shindo data — at the time I read that as just a shape mismatch in the payload.
What I hadn't registered was that 555 carried essentially no earthquake content at all. No hypocenter, no magnitude, nothing — not malformed, just absent, because it was never earthquake data to begin with. And it kept arriving every one to eight minutes, far too often for a genuine national EEW.

Reading the actual spec

Going back to P2P Earthquake Information's  EPSP specification  laid it out plainly:
code
name
meaning
551
JMAQuake
Earthquake information
552
JMATsunami
Tsunami forecast
554
EEWDetection
EEW announcement detected (chime only)
555
Areapeers
Geographic distribution of peers connected to the P2P network
556
EEW
Actual Earthquake Early Warning content
555 is Areapeers — network telemetry showing how many clients are connected in each region, completely unrelated to seismic activity. It gets broadcast on a regular schedule whether or not anything is shaking. That's why the hypocenter and magnitude fields were always empty: there was never earthquake data in that message to begin with.
The real EEW content — hypocenter, magnitude, per-region forecast intensity — lives in code 556. My connector had never subscribed to it.

Why I missed it

I'll be honest about the actual mistake: when I first read the API docs, I lumped 554 and 555 together as "the EEW codes" and moved on without registering that 556 existed at all. The  areas  field name in 555's payload happened to sound exactly like what a warning-area list should be called, so I built the parsing logic around that assumption instead of questioning it. Even after I noticed the real data didn't match what I expected, I explained it away as "EEW detail is often unavailable" rather than going back to the spec.
In the first post I wrote that mock data can't catch bugs that only show up against messy real traffic. This one was the opposite: I was looking at real data the whole time, and it still took a while to notice, because the payload technically parsed fine and produced something that looked plausible on screen.

The fix

I rewrote the connector's EEW type and message handling around code 556:
// before: treated 554 and 555 as "EEW"
export interface EewMessage {
code: 554 | 555;
// ...
}

// after: only 556 actually carries EEW content
export interface EewMessage {
code: 556;
earthquake?: { originTime?: string; hypocenter?: Hypocenter };
areas?: EewArea[]; // pref/name/scaleFrom/scaleTo, forecast-district granularity
}
As a side effect, EEW alerts now carry real per-region forecast intensity instead of the placeholder "strong shaking expected, details unknown" text I'd been showing before — an actual upgrade, not just a bug fix.
After redeploying to Fargate, the CloudWatch logs told the whole story: the once-a-minute "Earthquake Early Warning Detected" line disappeared entirely. Checking P2P's own history confirms genuine 556 messages only show up when there's an earthquake large enough to actually warrant one.

Closing thoughts

The root cause here was reading a field name, deciding it sounded right, and building on that assumption instead of checking the spec. Field names are a convenience, not documentation. I had a nagging feeling that something didn't add up for longer than I'd like to admit before I actually went and reread the source of truth. Next time, that instinct gets acted on immediately instead of explained away.

Series: Earthquake Alert (3 articles)

  1. 2
    The Earthquake Early Warnings My App Sent Weren't Real EEWs This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article