Skip to content

Instantly share code, notes, and snippets.

Created Nov 16, 2017
What would you like to do?
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
const char* ssid = "SSID";
const char* password = "pass";
WiFiServer server(80);
void setup() {
// Connecting to WiFi as an station
Serial.print("[WiFi] Connecting.");
WiFi.begin(ssid, password);
while(WiFi.status() != WL_CONNECTED) {
Serial.println(' ');
Serial.println("[WiFi] Connected to ssid: " + String(ssid));
Serial.print("[WiFi] IP: ");
// Start the MDNS server
if (MDNS.begin("esp-load-test")) {
Serial.println("[MDNS] Serving: esp-load-test.local");
String getHTMLHead(){
String htmlPage =
String("HTTP/1.1 200 OK\r\n") +
"Content-Type: application/octet-stream\r\n" +
"Content-Length: 999999999999\r\n" +
"Connection: close\r\n" +
return htmlPage;
void loop() {
WiFiClient client = server.available();
if (client && client.connected()) {
Serial.println("A client found.");
String line = client.readStringUntil('\n');
while(client.status()) {
const int bufSize = 1460;
// Initialize a random set of bytes
byte clientBuf[bufSize];
client.write((const uint8_t *)clientBuf, bufSize);
Serial.println("Client stopped.");

This comment has been minimized.

Copy link

@Bladetuab Bladetuab commented Apr 26, 2018

How can I run your code with my devices,
I don't know how to run your NodeJS file


This comment has been minimized.

Copy link

@vulcan25 vulcan25 commented May 16, 2019

@Bladetuab incase you never worked this out, or for others finding themselves here:

The node.js code appears to make a request to the / URL on the webserver.

So to do this without node, something like:

curl -vo /dev/null

...changing the IP to match what is displayed in the serial console. You could also hit that URL in a web-browser.

-o /dev/null ensures the file doesn't save locally, which is the purpose of the Node test client as per the tutorial.

I tested this code deployed to my NodeMCU w/ ESP8266 and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment