summaryrefslogblamecommitdiffstats
path: root/archives/extend/2013-April.txt
blob: b988707c4e84418e46b4ffa2915b8693d33d21b5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
From essen at ninenines.eu  Tue Apr  2 19:23:28 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Tue, 02 Apr 2013 19:23:28 +0200
Subject: [99s-extend] [ANN] Ranch 0.8.0
Message-ID: <[email protected]>

Just released!

We have greatly improved the performance of Ranch both for accepting 
connections and when they get disconnected. Stability has also been much 
improved thanks to many community provided tests.

Small API changes. Sorry!

  *  ListenerPid argument to Protocol:start_link/4 became Ref
  *  as a result it's now ranch:accept_ack(Ref)
  *  ranch_listener:remove_connection(ListenerPid) became 
ranch:remove_connection(Ref)

Unless you used ranch_listener_remove_connection/1 your old code should 
still work without any changes.

Enjoy!

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From essen at ninenines.eu  Wed Apr  3 17:21:16 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 03 Apr 2013 17:21:16 +0200
Subject: [99s-extend] [ANN] Cowboy 0.8.3
Message-ID: <[email protected]>

Hello!

Very small release just to update Ranch to 0.8.0 (faster!) and change 
something about streaming the body. Newly introduced init_stream/5 
proved to be a bad idea and got removed in favor of a new stream_body/2 
which allows specifying the maximum chunk size you want on a per chunk 
basis.

   https://github.com/extend/cowboy

Enjoy!

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From lee.sylvester at gmail.com  Wed Apr  3 21:33:20 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 3 Apr 2013 20:33:20 +0100
Subject: [99s-extend] Response headers
Message-ID: <[email protected]>

Hi list,

I'd like to set up my handler to use CORS.  Can anyone tell me how I can modify the headers for my handler to support this?

Thanks loads,
Lee

From Christopher.Phillips at turner.com  Wed Apr  3 22:35:36 2013
From: Christopher.Phillips at turner.com (Phillips, Christopher)
Date: Wed, 3 Apr 2013 20:35:36 +0000
Subject: [99s-extend] Response headers
In-Reply-To: <[email protected]>
Message-ID: <CD81FF59.4478%[email protected]>


  Sure. Right now, Cowboy doesn't parse the headers, but you can manually
parse them in your handler. I've got them working in my implementation
pretty well, I'll try and break it down a bit here.

  A good, basic overview of what the requests the browser will send, and
what your responses should look like, is here:
https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS



HANDLING PRE-FLIGHTS -
  Pre-flights are the OPTION requests the browser automatically sends off
when you make a CORS request using a verb other than GET, or POST with one
of three acceptable content types. They're defined well in the above link.

  You can read off the requested headers the actual call wants to send in
the OPTIONS preflight with

	{Headers, NewRequest } =
cowboy_req:header(<<"access-control-request-headers">>, Request)

  Headers will either be the binary, or undefined. If the binary, you
either need to manually parse it and choose to allow/disallow the request
from continuing based on it, or, if you just want to allow all headers
trivially, just pipe that back into the request, a la -

        Request2 = 
cowboy_req:set_resp_header(<<"access-control-allow-headers">>,
binary_to_list(Headers), NewRequest)

  (As a reminder, it can be undefined. You'll need to check for that
before passing it into the above. If it's undefined, you don't need to add
the access-control-allow-headers header).



  As part of the pre-flight request, you also need to handle what methods
are allowed. This looks something like -

	PreflightedRequest =
cowboy_req:set_resp_header(<<"access-control-allow-methods">>, <<"GET,
POST, DELETE, PUT">>, Request2)

  If I wanted to allow gets, posts, deletes, and puts. You can also choose
to read off the access-control-request-method header sent from the client,
but I don't see the point; your list of allowed methods doesn't need to
change based on that (the user is requesting a POST, why does that change
whether you allow a POST or not? But I digress).





FOR ALL CALLS (both pre-flights and the actual call)
  Respond with acceptable origin. If you want any domain to access this
resource (not advised, unless this is a public, readonly resource, but
good for testing), you can do -

  	NewRequest = 
cowboy_req:set_resp_header(<<"access-control-allow-origin">>, <<"*">>,
Request)


  If you want to filter out the allowed domains, it looks like -

	Origin = cowboy_req:header(<<"origin">>, Request) %Get the origin that
the browser sent you

        %Do logic to check Origin, and any other data that would decide
whether this request is allowed; it will only apply on a CORS request from
another browser.
        
	%If it passes, pass Origin back as the value for the
access-control-allow-origin header.
        NewRequest =
cowboy_req:set_resp_header(<<"access-control-allow-origin">>, Origin,
Request)



FOR ONLY THE ACTUAL CALL
  If you want to send custom headers back to your Javascript client (or
read any standard header beyond content-type), you need to explicitly
allow them. This looks like (if I wanted to expose the 'server' header so
my client Javascript can see that it's Cowboy on the backend) -

  	ExposedHeaderRequest =
cowboy_req:set_resp_header(<<"access-control-expose-headers">>,
<<"server">>, Request)




  That's basically it I believe. There is also a max age, and a allow
credentials header (which is really more of a require credentials);
they're pretty straightforwardly explained on that page I linked above,
but I haven't played with them personally.


  Caveats I ran into were largely being aware that same domain requests do
NOT supply any of the CORS headers, not even the origin header (so you can
get undefined and have to handle those cases), as well as understanding
the ramifications of allowing cross domain requests. Also, if you want to
develop while disconnected (or if it's not easy to grab another domain),
use your hosts file to declare a fake domain pointed to 127.0.0.1, load
your page from that, explicitly define your AJAX calls to localhost. Note
too that there is a bug in Firefox at present when you try and get all the
request headers. It returns an empty list. You can get individual ones if
you know the name (I.e., getResponseHeader("server") will work,
getAllResponseHeaders() returns an empty string). This is further
compounded by jQuery building its own XHR that loads headers by calling
getAllResponseHeaders, so in Firefox, using jQuery, you can get back zero
headers. Don't know if that affects you, but it's an issue it took me a
good while to diagnose, and which we've had to bear in mind.



   
On 4/3/13 3:33 PM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:

>Hi list,
>
>I'd like to set up my handler to use CORS.  Can anyone tell me how I can
>modify the headers for my handler to support this?
>
>Thanks loads,
>Lee
>_______________________________________________
>Extend mailing list
>Extend at lists.ninenines.eu
>http://lists.ninenines.eu:81/listinfo/extend
>




From lee.sylvester at gmail.com  Thu Apr  4 10:38:07 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 4 Apr 2013 09:38:07 +0100
Subject: [99s-extend] Response headers
In-Reply-To: <CD81FF59.4478%[email protected]>
References: <CD81FF59.4478%[email protected]>
Message-ID: <[email protected]>

Hi Christopher,

Thank you for that.  I will attempt to go through each piece today and solve the problem.  This is good advice; maybe it belongs in a blog post?  :-)

Thanks again,
Lee




On 3 Apr 2013, at 21:35, "Phillips, Christopher" <Christopher.Phillips at turner.com> wrote:

> 
>  Sure. Right now, Cowboy doesn't parse the headers, but you can manually
> parse them in your handler. I've got them working in my implementation
> pretty well, I'll try and break it down a bit here.
> 
>  A good, basic overview of what the requests the browser will send, and
> what your responses should look like, is here:
> https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS
> 
> 
> 
> HANDLING PRE-FLIGHTS -
>  Pre-flights are the OPTION requests the browser automatically sends off
> when you make a CORS request using a verb other than GET, or POST with one
> of three acceptable content types. They're defined well in the above link.
> 
>  You can read off the requested headers the actual call wants to send in
> the OPTIONS preflight with
> 
> 	{Headers, NewRequest } =
> cowboy_req:header(<<"access-control-request-headers">>, Request)
> 
>  Headers will either be the binary, or undefined. If the binary, you
> either need to manually parse it and choose to allow/disallow the request
> from continuing based on it, or, if you just want to allow all headers
> trivially, just pipe that back into the request, a la -
> 
>        Request2 = 
> cowboy_req:set_resp_header(<<"access-control-allow-headers">>,
> binary_to_list(Headers), NewRequest)
> 
>  (As a reminder, it can be undefined. You'll need to check for that
> before passing it into the above. If it's undefined, you don't need to add
> the access-control-allow-headers header).
> 
> 
> 
>  As part of the pre-flight request, you also need to handle what methods
> are allowed. This looks something like -
> 
> 	PreflightedRequest =
> cowboy_req:set_resp_header(<<"access-control-allow-methods">>, <<"GET,
> POST, DELETE, PUT">>, Request2)
> 
>  If I wanted to allow gets, posts, deletes, and puts. You can also choose
> to read off the access-control-request-method header sent from the client,
> but I don't see the point; your list of allowed methods doesn't need to
> change based on that (the user is requesting a POST, why does that change
> whether you allow a POST or not? But I digress).
> 
> 
> 
> 
> 
> FOR ALL CALLS (both pre-flights and the actual call)
>  Respond with acceptable origin. If you want any domain to access this
> resource (not advised, unless this is a public, readonly resource, but
> good for testing), you can do -
> 
>  	NewRequest = 
> cowboy_req:set_resp_header(<<"access-control-allow-origin">>, <<"*">>,
> Request)
> 
> 
>  If you want to filter out the allowed domains, it looks like -
> 
> 	Origin = cowboy_req:header(<<"origin">>, Request) %Get the origin that
> the browser sent you
> 
>        %Do logic to check Origin, and any other data that would decide
> whether this request is allowed; it will only apply on a CORS request from
> another browser.
> 
> 	%If it passes, pass Origin back as the value for the
> access-control-allow-origin header.
>        NewRequest =
> cowboy_req:set_resp_header(<<"access-control-allow-origin">>, Origin,
> Request)
> 
> 
> 
> FOR ONLY THE ACTUAL CALL
>  If you want to send custom headers back to your Javascript client (or
> read any standard header beyond content-type), you need to explicitly
> allow them. This looks like (if I wanted to expose the 'server' header so
> my client Javascript can see that it's Cowboy on the backend) -
> 
>  	ExposedHeaderRequest =
> cowboy_req:set_resp_header(<<"access-control-expose-headers">>,
> <<"server">>, Request)
> 
> 
> 
> 
>  That's basically it I believe. There is also a max age, and a allow
> credentials header (which is really more of a require credentials);
> they're pretty straightforwardly explained on that page I linked above,
> but I haven't played with them personally.
> 
> 
>  Caveats I ran into were largely being aware that same domain requests do
> NOT supply any of the CORS headers, not even the origin header (so you can
> get undefined and have to handle those cases), as well as understanding
> the ramifications of allowing cross domain requests. Also, if you want to
> develop while disconnected (or if it's not easy to grab another domain),
> use your hosts file to declare a fake domain pointed to 127.0.0.1, load
> your page from that, explicitly define your AJAX calls to localhost. Note
> too that there is a bug in Firefox at present when you try and get all the
> request headers. It returns an empty list. You can get individual ones if
> you know the name (I.e., getResponseHeader("server") will work,
> getAllResponseHeaders() returns an empty string). This is further
> compounded by jQuery building its own XHR that loads headers by calling
> getAllResponseHeaders, so in Firefox, using jQuery, you can get back zero
> headers. Don't know if that affects you, but it's an issue it took me a
> good while to diagnose, and which we've had to bear in mind.
> 
> 
> 
> 
> On 4/3/13 3:33 PM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:
> 
>> Hi list,
>> 
>> I'd like to set up my handler to use CORS.  Can anyone tell me how I can
>> modify the headers for my handler to support this?
>> 
>> Thanks loads,
>> Lee
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>> 
> 
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend



From lee.sylvester at gmail.com  Thu Apr  4 22:17:54 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 4 Apr 2013 21:17:54 +0100
Subject: [99s-extend] Bullet connection
Message-ID: <[email protected]>

Hi guys,

So, I'm using bullet in my Cowboy setup. There's a lot of tasks that take place before a connection is finally requested, but when it is requested, I see that the server is first called via HTTPS using method CONNECT.  The problem I have is that, while testing this on local host, this CONNECT request is throwing a 500 error, stating "SSL Proxying not enabled for this host: enable in Proxy Settings, SSL locations".

Does anyone know how I fix this to get past this problem?

Thanks,
Lee

From essen at ninenines.eu  Thu Apr  4 22:39:32 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Thu, 04 Apr 2013 22:39:32 +0200
Subject: [99s-extend] Bullet connection
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

On 04/04/2013 10:17 PM, Lee Sylvester wrote:
> Hi guys,
>
> So, I'm using bullet in my Cowboy setup. There's a lot of tasks that take place before a connection is finally requested, but when it is requested, I see that the server is first called via HTTPS using method CONNECT.  The problem I have is that, while testing this on local host, this CONNECT request is throwing a 500 error, stating "SSL Proxying not enabled for this host: enable in Proxy Settings, SSL locations".
>
> Does anyone know how I fix this to get past this problem?

You should probably disable the proxy you have configured in your 
browser for the domain localhost.

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From lee.sylvester at gmail.com  Thu Apr  4 22:54:54 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 4 Apr 2013 21:54:54 +0100
Subject: [99s-extend] Bullet connection
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

D'oh!  I'm obviously tired :(  Thanks for that.  I saw the message and instantly assumed it was a Cowboy related error.  Okay, so I got that fixed.  Now I need to work out why my connections close the instant they're open :-D  Oh, the life of a developer!

Thanks again.

Lee




On 4 Apr 2013, at 21:39, Lo?c Hoguin <essen at ninenines.eu> wrote:

> On 04/04/2013 10:17 PM, Lee Sylvester wrote:
>> Hi guys,
>> 
>> So, I'm using bullet in my Cowboy setup. There's a lot of tasks that take place before a connection is finally requested, but when it is requested, I see that the server is first called via HTTPS using method CONNECT.  The problem I have is that, while testing this on local host, this CONNECT request is throwing a 500 error, stating "SSL Proxying not enabled for this host: enable in Proxy Settings, SSL locations".
>> 
>> Does anyone know how I fix this to get past this problem?
> 
> You should probably disable the proxy you have configured in your browser for the domain localhost.
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From lee.sylvester at gmail.com  Mon Apr  8 15:53:38 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Mon, 8 Apr 2013 14:53:38 +0100
Subject: [99s-extend] Problems with Bullet
Message-ID: <[email protected]>

Hi all,

I'm currently having problems getting a websocket to connect to a simple bare bones Bullet handler.  Unfortunately, I'm still quite an Erlang noob, so the stack traces tend to lead me in circles.  I'm hoping this is obvious stuff to you Erlang pros :-)

Given the below handler:

init(_Transport, Req, _Opts, _Active) ->
	{ok, Req, undefined_state}.

stream(Data, Req, State) ->
	{ok, Req, State}.

info(Info, Req, State) ->
	{reply, Info, Req, State}.
	
terminate(_Req, _State) ->
	ok.

Connecting with a websocket throws the following error:

=ERROR REPORT==== 8-Apr-2013::14:46:11 ===
** Cowboy handler bullet_handler terminating in init/3
   for the reason error:undef
** Options were [{handler,connection_handler}]
** Request was [{socket,#Port<0.926>},
                {transport,ranch_tcp},
                {connection,keepalive},
                {pid,<0.491.0>},
                {method,<<"GET">>},
                {version,{1,1}},
                {peer,{{127,0,0,1},56630}},
                {host,<<"localhost">>},
                {host_info,undefined},
                {port,8080},
                {path,<<"/">>},
                {path_info,undefined},
                {qs,<<"encoding=text">>},
                {qs_vals,undefined},
                {fragment,<<>>},
                {bindings,[]},
                {headers,[{<<"upgrade">>,<<"websocket">>},
                          {<<"connection">>,<<"Upgrade">>},
                          {<<"host">>,<<"localhost:8080">>},
                          {<<"origin">>,<<"http://www.websocket.org">>},
                          {<<"pragma">>,<<"no-cache">>},
                          {<<"cache-control">>,<<"no-cache">>},
                          {<<"sec-websocket-key">>,
                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
                          {<<"sec-websocket-version">>,<<"13">>},
                          {<<"sec-websocket-extensions">>,
                           <<"x-webkit-deflate-frame">>}]},
                {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
                {cookies,undefined},
                {meta,[]},
                {body_state,waiting},
                {multipart,undefined},
                {buffer,<<>>},
                {resp_compress,false},
                {resp_state,waiting},
                {resp_headers,[]},
                {resp_body,<<>>},
                {onresponse,undefined}]
** Stacktrace: [{bullet_handler,init,
                    [{tcp,http},
                     {http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
                         <<"GET">>,
                         {1,1},
                         {{127,0,0,1},56630},
                         <<"localhost">>,undefined,8080,<<"/">>,
                         undefined,<<"encoding=text">>,undefined,<<>>,
                         [],
                         [{<<"upgrade">>,<<"websocket">>},
                          {<<"connection">>,<<"Upgrade">>},
                          {<<"host">>,<<"localhost:8080">>},
                          {<<"origin">>,<<"http://www.websocket.org">>},
                          {<<"pragma">>,<<"no-cache">>},
                          {<<"cache-control">>,<<"no-cache">>},
                          {<<"sec-websocket-key">>,
                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
                          {<<"sec-websocket-version">>,<<"13">>},
                          {<<"sec-websocket-extensions">>,
                           <<"x-webkit-deflate-frame">>}],
                         [{<<"connection">>,[<<"upgrade">>]}],
                         undefined,[],waiting,undefined,<<>>,false,waiting,[],
                         <<>>,undefined},
                     [{handler,connection_handler}]],
                    []},
                {cowboy_handler,handler_init,4,
                    [{file,"src/cowboy_handler.erl"},{line,69}]},
                {cowboy_protocol,execute,4,
                    [{file,"src/cowboy_protocol.erl"},{line,514}]}]

Can anyone see what might be throwing this off?  I'd like to get a minimal handler running before I attempt to add some logic.

Thanks,
Lee

From essen at ninenines.eu  Mon Apr  8 16:08:31 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Mon, 08 Apr 2013 16:08:31 +0200
Subject: [99s-extend] Problems with Bullet
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

Sounds like Bullet isn't in your path. Forgot -pa deps/*/ebin?

On 04/08/2013 03:53 PM, Lee Sylvester wrote:
> Hi all,
>
> I'm currently having problems getting a websocket to connect to a simple bare bones Bullet handler.  Unfortunately, I'm still quite an Erlang noob, so the stack traces tend to lead me in circles.  I'm hoping this is obvious stuff to you Erlang pros :-)
>
> Given the below handler:
>
> init(_Transport, Req, _Opts, _Active) ->
> 	{ok, Req, undefined_state}.
>
> stream(Data, Req, State) ->
> 	{ok, Req, State}.
>
> info(Info, Req, State) ->
> 	{reply, Info, Req, State}.
> 	
> terminate(_Req, _State) ->
> 	ok.
>
> Connecting with a websocket throws the following error:
>
> =ERROR REPORT==== 8-Apr-2013::14:46:11 ===
> ** Cowboy handler bullet_handler terminating in init/3
>     for the reason error:undef
> ** Options were [{handler,connection_handler}]
> ** Request was [{socket,#Port<0.926>},
>                  {transport,ranch_tcp},
>                  {connection,keepalive},
>                  {pid,<0.491.0>},
>                  {method,<<"GET">>},
>                  {version,{1,1}},
>                  {peer,{{127,0,0,1},56630}},
>                  {host,<<"localhost">>},
>                  {host_info,undefined},
>                  {port,8080},
>                  {path,<<"/">>},
>                  {path_info,undefined},
>                  {qs,<<"encoding=text">>},
>                  {qs_vals,undefined},
>                  {fragment,<<>>},
>                  {bindings,[]},
>                  {headers,[{<<"upgrade">>,<<"websocket">>},
>                            {<<"connection">>,<<"Upgrade">>},
>                            {<<"host">>,<<"localhost:8080">>},
>                            {<<"origin">>,<<"http://www.websocket.org">>},
>                            {<<"pragma">>,<<"no-cache">>},
>                            {<<"cache-control">>,<<"no-cache">>},
>                            {<<"sec-websocket-key">>,
>                             <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>                            {<<"sec-websocket-version">>,<<"13">>},
>                            {<<"sec-websocket-extensions">>,
>                             <<"x-webkit-deflate-frame">>}]},
>                  {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
>                  {cookies,undefined},
>                  {meta,[]},
>                  {body_state,waiting},
>                  {multipart,undefined},
>                  {buffer,<<>>},
>                  {resp_compress,false},
>                  {resp_state,waiting},
>                  {resp_headers,[]},
>                  {resp_body,<<>>},
>                  {onresponse,undefined}]
> ** Stacktrace: [{bullet_handler,init,
>                      [{tcp,http},
>                       {http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
>                           <<"GET">>,
>                           {1,1},
>                           {{127,0,0,1},56630},
>                           <<"localhost">>,undefined,8080,<<"/">>,
>                           undefined,<<"encoding=text">>,undefined,<<>>,
>                           [],
>                           [{<<"upgrade">>,<<"websocket">>},
>                            {<<"connection">>,<<"Upgrade">>},
>                            {<<"host">>,<<"localhost:8080">>},
>                            {<<"origin">>,<<"http://www.websocket.org">>},
>                            {<<"pragma">>,<<"no-cache">>},
>                            {<<"cache-control">>,<<"no-cache">>},
>                            {<<"sec-websocket-key">>,
>                             <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>                            {<<"sec-websocket-version">>,<<"13">>},
>                            {<<"sec-websocket-extensions">>,
>                             <<"x-webkit-deflate-frame">>}],
>                           [{<<"connection">>,[<<"upgrade">>]}],
>                           undefined,[],waiting,undefined,<<>>,false,waiting,[],
>                           <<>>,undefined},
>                       [{handler,connection_handler}]],
>                      []},
>                  {cowboy_handler,handler_init,4,
>                      [{file,"src/cowboy_handler.erl"},{line,69}]},
>                  {cowboy_protocol,execute,4,
>                      [{file,"src/cowboy_protocol.erl"},{line,514}]}]
>
> Can anyone see what might be throwing this off?  I'd like to get a minimal handler running before I attempt to add some logic.
>
> Thanks,
> Lee
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From Christopher.Phillips at turner.com  Mon Apr  8 16:11:44 2013
From: Christopher.Phillips at turner.com (Phillips, Christopher)
Date: Mon, 8 Apr 2013 14:11:44 +0000
Subject: [99s-extend] Problems with Bullet
In-Reply-To: <[email protected]>
Message-ID: <CD884493.47E3%[email protected]>

  Can you get the clock example working? I'm not sure why the initial
upgrade request would fail; are you exporting init/4 in your handler? Are
your dependencies consistent (I.e., blow them away and regrab them in case
it's an older version of cowboy with a new version of bullet, or vice
versa, maybe)? Either way, starting from the example would allow you to
start from a set of working code and either avoid the issue entirely, or
isolate it from your code.

On 4/8/13 9:53 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:

>Hi all,
>
>I'm currently having problems getting a websocket to connect to a simple
>bare bones Bullet handler.  Unfortunately, I'm still quite an Erlang
>noob, so the stack traces tend to lead me in circles.  I'm hoping this is
>obvious stuff to you Erlang pros :-)
>
>Given the below handler:
>
>init(_Transport, Req, _Opts, _Active) ->
>	{ok, Req, undefined_state}.
>
>stream(Data, Req, State) ->
>	{ok, Req, State}.
>
>info(Info, Req, State) ->
>	{reply, Info, Req, State}.
>	
>terminate(_Req, _State) ->
>	ok.
>
>Connecting with a websocket throws the following error:
>
>=ERROR REPORT==== 8-Apr-2013::14:46:11 ===
>** Cowboy handler bullet_handler terminating in init/3
>   for the reason error:undef
>** Options were [{handler,connection_handler}]
>** Request was [{socket,#Port<0.926>},
>                {transport,ranch_tcp},
>                {connection,keepalive},
>                {pid,<0.491.0>},
>                {method,<<"GET">>},
>                {version,{1,1}},
>                {peer,{{127,0,0,1},56630}},
>                {host,<<"localhost">>},
>                {host_info,undefined},
>                {port,8080},
>                {path,<<"/">>},
>                {path_info,undefined},
>                {qs,<<"encoding=text">>},
>                {qs_vals,undefined},
>                {fragment,<<>>},
>                {bindings,[]},
>                {headers,[{<<"upgrade">>,<<"websocket">>},
>                          {<<"connection">>,<<"Upgrade">>},
>                          {<<"host">>,<<"localhost:8080">>},
>                          {<<"origin">>,<<"http://www.websocket.org">>},
>                          {<<"pragma">>,<<"no-cache">>},
>                          {<<"cache-control">>,<<"no-cache">>},
>                          {<<"sec-websocket-key">>,
>                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>                          {<<"sec-websocket-version">>,<<"13">>},
>                          {<<"sec-websocket-extensions">>,
>                           <<"x-webkit-deflate-frame">>}]},
>                {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
>                {cookies,undefined},
>                {meta,[]},
>                {body_state,waiting},
>                {multipart,undefined},
>                {buffer,<<>>},
>                {resp_compress,false},
>                {resp_state,waiting},
>                {resp_headers,[]},
>                {resp_body,<<>>},
>                {onresponse,undefined}]
>** Stacktrace: [{bullet_handler,init,
>                    [{tcp,http},
>                     {http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
>                         <<"GET">>,
>                         {1,1},
>                         {{127,0,0,1},56630},
>                         <<"localhost">>,undefined,8080,<<"/">>,
>                         undefined,<<"encoding=text">>,undefined,<<>>,
>                         [],
>                         [{<<"upgrade">>,<<"websocket">>},
>                          {<<"connection">>,<<"Upgrade">>},
>                          {<<"host">>,<<"localhost:8080">>},
>                          {<<"origin">>,<<"http://www.websocket.org">>},
>                          {<<"pragma">>,<<"no-cache">>},
>                          {<<"cache-control">>,<<"no-cache">>},
>                          {<<"sec-websocket-key">>,
>                           <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>                          {<<"sec-websocket-version">>,<<"13">>},
>                          {<<"sec-websocket-extensions">>,
>                           <<"x-webkit-deflate-frame">>}],
>                         [{<<"connection">>,[<<"upgrade">>]}],
>                  
>undefined,[],waiting,undefined,<<>>,false,waiting,[],
>                         <<>>,undefined},
>                     [{handler,connection_handler}]],
>                    []},
>                {cowboy_handler,handler_init,4,
>                    [{file,"src/cowboy_handler.erl"},{line,69}]},
>                {cowboy_protocol,execute,4,
>                    [{file,"src/cowboy_protocol.erl"},{line,514}]}]
>
>Can anyone see what might be throwing this off?  I'd like to get a
>minimal handler running before I attempt to add some logic.
>
>Thanks,
>Lee
>_______________________________________________
>Extend mailing list
>Extend at lists.ninenines.eu
>http://lists.ninenines.eu:81/listinfo/extend
>




From Christopher.Phillips at turner.com  Mon Apr  8 16:18:27 2013
From: Christopher.Phillips at turner.com (Phillips, Christopher)
Date: Mon, 8 Apr 2013 14:18:27 +0000
Subject: [99s-extend] Problems with Bullet
In-Reply-To: <[email protected]>
Message-ID: <CD8849A5.4807%[email protected]>

  *facepalm* Or that, yeah. Should have correlated the stack trace with
the error. Not used to seeing cowboy run as the app, not a dependency.

On 4/8/13 10:08 AM, "Lo?c Hoguin" <essen at ninenines.eu> wrote:

>Sounds like Bullet isn't in your path. Forgot -pa deps/*/ebin?
>
>On 04/08/2013 03:53 PM, Lee Sylvester wrote:
>> Hi all,
>>
>> I'm currently having problems getting a websocket to connect to a
>>simple bare bones Bullet handler.  Unfortunately, I'm still quite an
>>Erlang noob, so the stack traces tend to lead me in circles.  I'm hoping
>>this is obvious stuff to you Erlang pros :-)
>>
>> Given the below handler:
>>
>> init(_Transport, Req, _Opts, _Active) ->
>> 	{ok, Req, undefined_state}.
>>
>> stream(Data, Req, State) ->
>> 	{ok, Req, State}.
>>
>> info(Info, Req, State) ->
>> 	{reply, Info, Req, State}.
>> 	
>> terminate(_Req, _State) ->
>> 	ok.
>>
>> Connecting with a websocket throws the following error:
>>
>> =ERROR REPORT==== 8-Apr-2013::14:46:11 ===
>> ** Cowboy handler bullet_handler terminating in init/3
>>     for the reason error:undef
>> ** Options were [{handler,connection_handler}]
>> ** Request was [{socket,#Port<0.926>},
>>                  {transport,ranch_tcp},
>>                  {connection,keepalive},
>>                  {pid,<0.491.0>},
>>                  {method,<<"GET">>},
>>                  {version,{1,1}},
>>                  {peer,{{127,0,0,1},56630}},
>>                  {host,<<"localhost">>},
>>                  {host_info,undefined},
>>                  {port,8080},
>>                  {path,<<"/">>},
>>                  {path_info,undefined},
>>                  {qs,<<"encoding=text">>},
>>                  {qs_vals,undefined},
>>                  {fragment,<<>>},
>>                  {bindings,[]},
>>                  {headers,[{<<"upgrade">>,<<"websocket">>},
>>                            {<<"connection">>,<<"Upgrade">>},
>>                            {<<"host">>,<<"localhost:8080">>},
>>                 
>>{<<"origin">>,<<"http://www.websocket.org">>},
>>                            {<<"pragma">>,<<"no-cache">>},
>>                            {<<"cache-control">>,<<"no-cache">>},
>>                            {<<"sec-websocket-key">>,
>>                             <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>>                            {<<"sec-websocket-version">>,<<"13">>},
>>                            {<<"sec-websocket-extensions">>,
>>                             <<"x-webkit-deflate-frame">>}]},
>>                  {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
>>                  {cookies,undefined},
>>                  {meta,[]},
>>                  {body_state,waiting},
>>                  {multipart,undefined},
>>                  {buffer,<<>>},
>>                  {resp_compress,false},
>>                  {resp_state,waiting},
>>                  {resp_headers,[]},
>>                  {resp_body,<<>>},
>>                  {onresponse,undefined}]
>> ** Stacktrace: [{bullet_handler,init,
>>                      [{tcp,http},
>>                 
>>{http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
>>                           <<"GET">>,
>>                           {1,1},
>>                           {{127,0,0,1},56630},
>>                           <<"localhost">>,undefined,8080,<<"/">>,
>>                           undefined,<<"encoding=text">>,undefined,<<>>,
>>                           [],
>>                           [{<<"upgrade">>,<<"websocket">>},
>>                            {<<"connection">>,<<"Upgrade">>},
>>                            {<<"host">>,<<"localhost:8080">>},
>>                 
>>{<<"origin">>,<<"http://www.websocket.org">>},
>>                            {<<"pragma">>,<<"no-cache">>},
>>                            {<<"cache-control">>,<<"no-cache">>},
>>                            {<<"sec-websocket-key">>,
>>                             <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>>                            {<<"sec-websocket-version">>,<<"13">>},
>>                            {<<"sec-websocket-extensions">>,
>>                             <<"x-webkit-deflate-frame">>}],
>>                           [{<<"connection">>,[<<"upgrade">>]}],
>>                 
>>undefined,[],waiting,undefined,<<>>,false,waiting,[],
>>                           <<>>,undefined},
>>                       [{handler,connection_handler}]],
>>                      []},
>>                  {cowboy_handler,handler_init,4,
>>                      [{file,"src/cowboy_handler.erl"},{line,69}]},
>>                  {cowboy_protocol,execute,4,
>>                      [{file,"src/cowboy_protocol.erl"},{line,514}]}]
>>
>> Can anyone see what might be throwing this off?  I'd like to get a
>>minimal handler running before I attempt to add some logic.
>>
>> Thanks,
>> Lee
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>>
>
>
>-- 
>Lo?c Hoguin
>Erlang Cowboy
>Nine Nines
>http://ninenines.eu
>_______________________________________________
>Extend mailing list
>Extend at lists.ninenines.eu
>http://lists.ninenines.eu:81/listinfo/extend
>




From lee.sylvester at gmail.com  Mon Apr  8 16:21:53 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Mon, 8 Apr 2013 15:21:53 +0100
Subject: [99s-extend] Problems with Bullet
In-Reply-To: <CD8849A5.4807%[email protected]>
References: <CD8849A5.4807%[email protected]>
Message-ID: <[email protected]>

Thanks guys,  that was exactly the problem.  I feel a little stupid :-)  I use Rebar to compile my apps, but none of the three books I have on Erlang describe the config files in much detail.  I probably have my entire setup wrong.

Anyhow, it looks to be working, now :-)

Thanks again,
Lee



On 8 Apr 2013, at 15:18, "Phillips, Christopher" <Christopher.Phillips at turner.com> wrote:

>  *facepalm* Or that, yeah. Should have correlated the stack trace with
> the error. Not used to seeing cowboy run as the app, not a dependency.
> 
> On 4/8/13 10:08 AM, "Lo?c Hoguin" <essen at ninenines.eu> wrote:
> 
>> Sounds like Bullet isn't in your path. Forgot -pa deps/*/ebin?
>> 
>> On 04/08/2013 03:53 PM, Lee Sylvester wrote:
>>> Hi all,
>>> 
>>> I'm currently having problems getting a websocket to connect to a
>>> simple bare bones Bullet handler.  Unfortunately, I'm still quite an
>>> Erlang noob, so the stack traces tend to lead me in circles.  I'm hoping
>>> this is obvious stuff to you Erlang pros :-)
>>> 
>>> Given the below handler:
>>> 
>>> init(_Transport, Req, _Opts, _Active) ->
>>> 	{ok, Req, undefined_state}.
>>> 
>>> stream(Data, Req, State) ->
>>> 	{ok, Req, State}.
>>> 
>>> info(Info, Req, State) ->
>>> 	{reply, Info, Req, State}.
>>> 	
>>> terminate(_Req, _State) ->
>>> 	ok.
>>> 
>>> Connecting with a websocket throws the following error:
>>> 
>>> =ERROR REPORT==== 8-Apr-2013::14:46:11 ===
>>> ** Cowboy handler bullet_handler terminating in init/3
>>>    for the reason error:undef
>>> ** Options were [{handler,connection_handler}]
>>> ** Request was [{socket,#Port<0.926>},
>>>                 {transport,ranch_tcp},
>>>                 {connection,keepalive},
>>>                 {pid,<0.491.0>},
>>>                 {method,<<"GET">>},
>>>                 {version,{1,1}},
>>>                 {peer,{{127,0,0,1},56630}},
>>>                 {host,<<"localhost">>},
>>>                 {host_info,undefined},
>>>                 {port,8080},
>>>                 {path,<<"/">>},
>>>                 {path_info,undefined},
>>>                 {qs,<<"encoding=text">>},
>>>                 {qs_vals,undefined},
>>>                 {fragment,<<>>},
>>>                 {bindings,[]},
>>>                 {headers,[{<<"upgrade">>,<<"websocket">>},
>>>                           {<<"connection">>,<<"Upgrade">>},
>>>                           {<<"host">>,<<"localhost:8080">>},
>>> 
>>> {<<"origin">>,<<"http://www.websocket.org">>},
>>>                           {<<"pragma">>,<<"no-cache">>},
>>>                           {<<"cache-control">>,<<"no-cache">>},
>>>                           {<<"sec-websocket-key">>,
>>>                            <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>>>                           {<<"sec-websocket-version">>,<<"13">>},
>>>                           {<<"sec-websocket-extensions">>,
>>>                            <<"x-webkit-deflate-frame">>}]},
>>>                 {p_headers,[{<<"connection">>,[<<"upgrade">>]}]},
>>>                 {cookies,undefined},
>>>                 {meta,[]},
>>>                 {body_state,waiting},
>>>                 {multipart,undefined},
>>>                 {buffer,<<>>},
>>>                 {resp_compress,false},
>>>                 {resp_state,waiting},
>>>                 {resp_headers,[]},
>>>                 {resp_body,<<>>},
>>>                 {onresponse,undefined}]
>>> ** Stacktrace: [{bullet_handler,init,
>>>                     [{tcp,http},
>>> 
>>> {http_req,#Port<0.926>,ranch_tcp,keepalive,<0.491.0>,
>>>                          <<"GET">>,
>>>                          {1,1},
>>>                          {{127,0,0,1},56630},
>>>                          <<"localhost">>,undefined,8080,<<"/">>,
>>>                          undefined,<<"encoding=text">>,undefined,<<>>,
>>>                          [],
>>>                          [{<<"upgrade">>,<<"websocket">>},
>>>                           {<<"connection">>,<<"Upgrade">>},
>>>                           {<<"host">>,<<"localhost:8080">>},
>>> 
>>> {<<"origin">>,<<"http://www.websocket.org">>},
>>>                           {<<"pragma">>,<<"no-cache">>},
>>>                           {<<"cache-control">>,<<"no-cache">>},
>>>                           {<<"sec-websocket-key">>,
>>>                            <<"fEj/SOOcQgSKATOjhbNJBQ==">>},
>>>                           {<<"sec-websocket-version">>,<<"13">>},
>>>                           {<<"sec-websocket-extensions">>,
>>>                            <<"x-webkit-deflate-frame">>}],
>>>                          [{<<"connection">>,[<<"upgrade">>]}],
>>> 
>>> undefined,[],waiting,undefined,<<>>,false,waiting,[],
>>>                          <<>>,undefined},
>>>                      [{handler,connection_handler}]],
>>>                     []},
>>>                 {cowboy_handler,handler_init,4,
>>>                     [{file,"src/cowboy_handler.erl"},{line,69}]},
>>>                 {cowboy_protocol,execute,4,
>>>                     [{file,"src/cowboy_protocol.erl"},{line,514}]}]
>>> 
>>> Can anyone see what might be throwing this off?  I'd like to get a
>>> minimal handler running before I attempt to add some logic.
>>> 
>>> Thanks,
>>> Lee
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>>> 
>> 
>> 
>> -- 
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>> 
> 
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend



From lee.sylvester at gmail.com  Wed Apr 10 13:47:45 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 10 Apr 2013 12:47:45 +0100
Subject: [99s-extend] Heartbeat?
Message-ID: <[email protected]>

Hey guys,

So, my bullet websockets are going great.  However, I have a question.  At present, if I don't send any data to or from my websockets for a while, the connection closes after about 10 - 20 seconds.  Therefore, should I send a heartbeat to the client from Erlang to keep this open?  The websockets are for user to user messaging, so it's possible that large periods of inactivity could occur.

Thanks,
Lee

From sasa.juric at gmail.com  Wed Apr 10 14:00:47 2013
From: sasa.juric at gmail.com (Sasa Juric)
Date: Wed, 10 Apr 2013 14:00:47 +0200
Subject: [99s-extend] cowboy and chromium
Message-ID: <[email protected]>

Hi,

I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.

After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.

If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.

After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.

However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem. 
The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives. 
This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.

This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?

Thank you very much in advance and best regards,
Sasa

From essen at ninenines.eu  Wed Apr 10 16:38:26 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 10 Apr 2013 16:38:26 +0200
Subject: [99s-extend] Heartbeat?
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

On 04/10/2013 01:47 PM, Lee Sylvester wrote:
> Hey guys,
>
> So, my bullet websockets are going great.  However, I have a question.  At present, if I don't send any data to or from my websockets for a while, the connection closes after about 10 - 20 seconds.  Therefore, should I send a heartbeat to the client from Erlang to keep this open?  The websockets are for user to user messaging, so it's possible that large periods of inactivity could occur.

Send one from the client if you want it to scale. Bullet provides you 
with one callback that you can use to send anything. If you're using 
JSON then sending {} is generally enough.

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From essen at ninenines.eu  Wed Apr 10 16:41:21 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 10 Apr 2013 16:41:21 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

On 04/10/2013 02:00 PM, Sasa Juric wrote:
> Hi,
>
> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>
> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>
> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>
> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>
> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>
> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?

Haven't seen this happen on plain Cowboy. The proxy might be the 
culprit. See if you can reproduce without the proxy.

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From sasa.juric at gmail.com  Wed Apr 10 16:50:31 2013
From: sasa.juric at gmail.com (Sasa Juric)
Date: Wed, 10 Apr 2013 16:50:31 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.

Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.

Question: can I configure keep-alive timeout in Cowboy?


On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:

> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>> Hi,
>> 
>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>> 
>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>> 
>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>> 
>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>> 
>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>> 
>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
> 
> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From essen at ninenines.eu  Wed Apr 10 16:51:50 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 10 Apr 2013 16:51:50 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

'timeout' protocol option, in milliseconds.

On 04/10/2013 04:50 PM, Sasa Juric wrote:
> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>
> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>
> Question: can I configure keep-alive timeout in Cowboy?
>
>
> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>
>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>> Hi,
>>>
>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>
>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>
>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>
>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>
>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>
>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>
>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From lee.sylvester at gmail.com  Wed Apr 10 16:53:24 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Wed, 10 Apr 2013 15:53:24 +0100
Subject: [99s-extend] Heartbeat?
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Ahh, thank you.

Regards,
Lee



On 10 Apr 2013, at 15:38, Lo?c Hoguin <essen at ninenines.eu> wrote:

> On 04/10/2013 01:47 PM, Lee Sylvester wrote:
>> Hey guys,
>> 
>> So, my bullet websockets are going great.  However, I have a question.  At present, if I don't send any data to or from my websockets for a while, the connection closes after about 10 - 20 seconds.  Therefore, should I send a heartbeat to the client from Erlang to keep this open?  The websockets are for user to user messaging, so it's possible that large periods of inactivity could occur.
> 
> Send one from the client if you want it to scale. Bullet provides you with one callback that you can use to send anything. If you're using JSON then sending {} is generally enough.
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From sasa.juric at gmail.com  Wed Apr 10 16:56:08 2013
From: sasa.juric at gmail.com (Sasa Juric)
Date: Wed, 10 Apr 2013 16:56:08 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Thanks!

I was looking at the option, but was confused by description which states:
Time in milliseconds a client has to send the full request line and headers.

I'll give it a try and see how it works.

Best regards,
Sasa

On Apr 10, 2013, at 4:51 PM, Lo?c Hoguin wrote:

> 'timeout' protocol option, in milliseconds.
> 
> On 04/10/2013 04:50 PM, Sasa Juric wrote:
>> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>> 
>> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
>> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
>> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>> 
>> Question: can I configure keep-alive timeout in Cowboy?
>> 
>> 
>> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>> 
>>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>>> Hi,
>>>> 
>>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>> 
>>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>> 
>>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>> 
>>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>> 
>>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>> 
>>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>> 
>>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>> 
>>> --
>>> Lo?c Hoguin
>>> Erlang Cowboy
>>> Nine Nines
>>> http://ninenines.eu
>> 
> 
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From essen at ninenines.eu  Wed Apr 10 17:01:14 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 10 Apr 2013 17:01:14 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Means it's not a read timeout, but a timeout for the whole request up to 
and excluding the body (so an intentionally slow client will get 
disconnected at 5s).

On 04/10/2013 04:56 PM, Sasa Juric wrote:
> Thanks!
>
> I was looking at the option, but was confused by description which states:
> Time in milliseconds a client has to send the full request line and headers.
>
> I'll give it a try and see how it works.
>
> Best regards,
> Sasa
>
> On Apr 10, 2013, at 4:51 PM, Lo?c Hoguin wrote:
>
>> 'timeout' protocol option, in milliseconds.
>>
>> On 04/10/2013 04:50 PM, Sasa Juric wrote:
>>> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>>>
>>> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
>>> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
>>> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>>>
>>> Question: can I configure keep-alive timeout in Cowboy?
>>>
>>>
>>> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>>>
>>>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>>>> Hi,
>>>>>
>>>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>>>
>>>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>>>
>>>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>>>
>>>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>>>
>>>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>>>
>>>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>>>
>>>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>>>
>>>> --
>>>> Lo?c Hoguin
>>>> Erlang Cowboy
>>>> Nine Nines
>>>> http://ninenines.eu
>>>
>>
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From sasa.juric at gmail.com  Wed Apr 10 17:05:51 2013
From: sasa.juric at gmail.com (Sasa Juric)
Date: Wed, 10 Apr 2013 17:05:51 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Ok, just to make sure I understand:
When I serve a request, and the connection is not closed due to keep-alive, will this timeout also apply?


On Apr 10, 2013, at 5:01 PM, Lo?c Hoguin wrote:

> Means it's not a read timeout, but a timeout for the whole request up to and excluding the body (so an intentionally slow client will get disconnected at 5s).
> 
> On 04/10/2013 04:56 PM, Sasa Juric wrote:
>> Thanks!
>> 
>> I was looking at the option, but was confused by description which states:
>> Time in milliseconds a client has to send the full request line and headers.
>> 
>> I'll give it a try and see how it works.
>> 
>> Best regards,
>> Sasa
>> 
>> On Apr 10, 2013, at 4:51 PM, Lo?c Hoguin wrote:
>> 
>>> 'timeout' protocol option, in milliseconds.
>>> 
>>> On 04/10/2013 04:50 PM, Sasa Juric wrote:
>>>> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>>>> 
>>>> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
>>>> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
>>>> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>>>> 
>>>> Question: can I configure keep-alive timeout in Cowboy?
>>>> 
>>>> 
>>>> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>>>> 
>>>>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>>>>> Hi,
>>>>>> 
>>>>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>>>> 
>>>>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>>>> 
>>>>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>>>> 
>>>>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>>>> 
>>>>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>>>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>>>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>>>> 
>>>>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>>>> 
>>>>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>>>> 
>>>>> --
>>>>> Lo?c Hoguin
>>>>> Erlang Cowboy
>>>>> Nine Nines
>>>>> http://ninenines.eu
>>>> 
>>> 
>>> 
>>> --
>>> Lo?c Hoguin
>>> Erlang Cowboy
>>> Nine Nines
>>> http://ninenines.eu
>> 
> 
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From essen at ninenines.eu  Wed Apr 10 17:07:18 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Wed, 10 Apr 2013 17:07:18 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

It's running from the moment Cowboy starts expecting a new request up to 
the moment it got the request in full (excluding the body), then it's 
reset for the next request.

On 04/10/2013 05:05 PM, Sasa Juric wrote:
> Ok, just to make sure I understand:
> When I serve a request, and the connection is not closed due to keep-alive, will this timeout also apply?
>
>
> On Apr 10, 2013, at 5:01 PM, Lo?c Hoguin wrote:
>
>> Means it's not a read timeout, but a timeout for the whole request up to and excluding the body (so an intentionally slow client will get disconnected at 5s).
>>
>> On 04/10/2013 04:56 PM, Sasa Juric wrote:
>>> Thanks!
>>>
>>> I was looking at the option, but was confused by description which states:
>>> Time in milliseconds a client has to send the full request line and headers.
>>>
>>> I'll give it a try and see how it works.
>>>
>>> Best regards,
>>> Sasa
>>>
>>> On Apr 10, 2013, at 4:51 PM, Lo?c Hoguin wrote:
>>>
>>>> 'timeout' protocol option, in milliseconds.
>>>>
>>>> On 04/10/2013 04:50 PM, Sasa Juric wrote:
>>>>> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>>>>>
>>>>> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
>>>>> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
>>>>> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>>>>>
>>>>> Question: can I configure keep-alive timeout in Cowboy?
>>>>>
>>>>>
>>>>> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>>>>>
>>>>>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>>>>>
>>>>>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>>>>>
>>>>>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>>>>>
>>>>>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>>>>>
>>>>>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>>>>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>>>>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>>>>>
>>>>>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>>>>>
>>>>>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>>>>>
>>>>>> --
>>>>>> Lo?c Hoguin
>>>>>> Erlang Cowboy
>>>>>> Nine Nines
>>>>>> http://ninenines.eu
>>>>>
>>>>
>>>>
>>>> --
>>>> Lo?c Hoguin
>>>> Erlang Cowboy
>>>> Nine Nines
>>>> http://ninenines.eu
>>>
>>
>>
>> --
>> Lo?c Hoguin
>> Erlang Cowboy
>> Nine Nines
>> http://ninenines.eu
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From sasa.juric at gmail.com  Wed Apr 10 17:11:57 2013
From: sasa.juric at gmail.com (Sasa Juric)
Date: Wed, 10 Apr 2013 17:11:57 +0200
Subject: [99s-extend] cowboy and chromium
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Thanks!

On Apr 10, 2013, at 5:07 PM, Lo?c Hoguin wrote:

> It's running from the moment Cowboy starts expecting a new request up to the moment it got the request in full (excluding the body), then it's reset for the next request.
> 
> On 04/10/2013 05:05 PM, Sasa Juric wrote:
>> Ok, just to make sure I understand:
>> When I serve a request, and the connection is not closed due to keep-alive, will this timeout also apply?
>> 
>> 
>> On Apr 10, 2013, at 5:01 PM, Lo?c Hoguin wrote:
>> 
>>> Means it's not a read timeout, but a timeout for the whole request up to and excluding the body (so an intentionally slow client will get disconnected at 5s).
>>> 
>>> On 04/10/2013 04:56 PM, Sasa Juric wrote:
>>>> Thanks!
>>>> 
>>>> I was looking at the option, but was confused by description which states:
>>>> Time in milliseconds a client has to send the full request line and headers.
>>>> 
>>>> I'll give it a try and see how it works.
>>>> 
>>>> Best regards,
>>>> Sasa
>>>> 
>>>> On Apr 10, 2013, at 4:51 PM, Lo?c Hoguin wrote:
>>>> 
>>>>> 'timeout' protocol option, in milliseconds.
>>>>> 
>>>>> On 04/10/2013 04:50 PM, Sasa Juric wrote:
>>>>>> I agree with you. In addition, I can't reproduce without the proxy, which confirms the suspicion.
>>>>>> 
>>>>>> Looking at the code of mochiweb which I was using, the connection timeout is set to 5 minutes.
>>>>>> The other factor, which I can confirm is that when the server terminates the connection, the proxy doesn't forward this to the client. Hence, the client and proxy probably "think" that connection is still active, and try to reuse it, but this doesn't work until timeout.
>>>>>> Other browsers probably can gracefully handle this situation, but for some reason chromium is stuck to 60 seconds and after retry it presumably opens new connection and succeeds.
>>>>>> 
>>>>>> Question: can I configure keep-alive timeout in Cowboy?
>>>>>> 
>>>>>> 
>>>>>> On Apr 10, 2013, at 4:41 PM, Lo?c Hoguin wrote:
>>>>>> 
>>>>>>> On 04/10/2013 02:00 PM, Sasa Juric wrote:
>>>>>>>> Hi,
>>>>>>>> 
>>>>>>>> I have recently in my production system replaced mochiweb with cowboy. The server generally works fine, except for a bizarre behavior which I cannot quite explain, so I post here, hoping to get some pointers.
>>>>>>>> 
>>>>>>>> After replacing mochiweb with cowboy, I noticed that in chromium (other major browsers work fine) often (but not always) a request lasts a little more than a minute. Further inspection in chrome://net-internals showed that browser tries to send a request, times out after 60 sec, retries and then succeeds immediately. The key point is that it doesn't happen always. First couple of requests work fine, then all of a sudden one doesn't work. At the same time requests from other browsers (including chrome) on the same machine work fine.
>>>>>>>> 
>>>>>>>> If I revert to mochiweb, the problem disappears. Other than web server related code, everything else is the same: the rest of my code, the server setup etc... In addition, I return same responses and headers in both versions.
>>>>>>>> 
>>>>>>>> After many attempts and failures, I might have worked around the issue. Namely, I included <<"connection">>, <<"close">> in all responses. After this change, it seems that long requests are not occurring. In any case, I can't reproduce it anymore, whereas before the change I could have reproduce it easily.
>>>>>>>> 
>>>>>>>> However, I'm not sure if I have really resolved the issue, I'm also not happy with connection closes since it degrades performance. And finally, I'm not sure if I quite understand the problem.
>>>>>>>> The only theory I have is that due to keep-alive, chromium holds the connection, while cowboy closes it (I read somewhere that hardcoded timeout is 5 seconds, right?). In this case it might happen that chromium sends a request to a non existing socket and then hangs for a minute, waiting for the response which never arrives.
>>>>>>>> This might further be amplified by the fact that in production, between browser and cowboy, there is a proxy/load balancer, so maybe load balancer still holds the connection despite the fact that server had closed it.
>>>>>>>> 
>>>>>>>> This is the only theory I currently have, and I would like to hear if you guys have some other idea or any kind of helpful pointer?
>>>>>>> 
>>>>>>> Haven't seen this happen on plain Cowboy. The proxy might be the culprit. See if you can reproduce without the proxy.
>>>>>>> 
>>>>>>> --
>>>>>>> Lo?c Hoguin
>>>>>>> Erlang Cowboy
>>>>>>> Nine Nines
>>>>>>> http://ninenines.eu
>>>>>> 
>>>>> 
>>>>> 
>>>>> --
>>>>> Lo?c Hoguin
>>>>> Erlang Cowboy
>>>>> Nine Nines
>>>>> http://ninenines.eu
>>>> 
>>> 
>>> 
>>> --
>>> Lo?c Hoguin
>>> Erlang Cowboy
>>> Nine Nines
>>> http://ninenines.eu
>> 
> 
> 
> -- 
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu



From lee.sylvester at gmail.com  Thu Apr 11 07:51:12 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 11 Apr 2013 06:51:12 +0100
Subject: [99s-extend] Distributed model?
Message-ID: <[email protected]>

Hi guys,

So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.

I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?

Thanks,
Lee

From jeremy at quarkgames.com  Thu Apr 11 08:29:16 2013
From: jeremy at quarkgames.com (Jeremy Ong)
Date: Wed, 10 Apr 2013 23:29:16 -0700
Subject: [99s-extend] Distributed model?
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>

Make all the machines identically and add an haproxy (or equivalent)
machine to load balance between all of them. Haproxy can handle many
many requests. Keep in mind that with tcp, the load balancer is just
accepting the socket but then the client communicates with the actual
application server directly afterwards.

On Wed, Apr 10, 2013 at 10:51 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
> Hi guys,
>
> So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.
>
> I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?
>
> Thanks,
> Lee
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend


From lee.sylvester at gmail.com  Thu Apr 11 08:49:18 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 11 Apr 2013 07:49:18 +0100
Subject: [99s-extend] Distributed model?
In-Reply-To: <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>
References: <[email protected]>
 <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>
Message-ID: <[email protected]>

Thanks Jeremy, but what about inter-node communication?  If I have a user on node A sending a message to 10k users located on 10 other nodes, what is the best way to handle that?  Especially if this user is sending several messages and expecting replies.  Should I use the standard Erlang inter-process messaging or should I implement an MQ on top to handle this?

Thanks,
Lee


On 11 Apr 2013, at 07:29, Jeremy Ong <jeremy at quarkgames.com> wrote:

> Make all the machines identically and add an haproxy (or equivalent)
> machine to load balance between all of them. Haproxy can handle many
> many requests. Keep in mind that with tcp, the load balancer is just
> accepting the socket but then the client communicates with the actual
> application server directly afterwards.
> 
> On Wed, Apr 10, 2013 at 10:51 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>> Hi guys,
>> 
>> So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.
>> 
>> I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?
>> 
>> Thanks,
>> Lee
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend



From jeremy at quarkgames.com  Thu Apr 11 09:04:04 2013
From: jeremy at quarkgames.com (Jeremy Ong)
Date: Thu, 11 Apr 2013 00:04:04 -0700
Subject: [99s-extend] Distributed model?
In-Reply-To: <[email protected]>
References: <[email protected]>
 <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>
 <[email protected]>
Message-ID: <CAKD1GY4xtZWXvfqstapnpLskbn3DFPPGDO9yHTLHDmTP+ozR7A@mail.gmail.com>

I see. I assume this is for a chat server of some sort?

You don't want the user process sending all these messages because the
user process wouldn't be able to do anything useful (like receive
messages) in the meantime.

Better is to implement a pubsub process for each channel of
communication (i.e. one process per room) or rely on Redis pubsub or
something if speed is extremely important.

There is no way to get around the O(N) complexity of broadcasting.

On Wed, Apr 10, 2013 at 11:49 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
> Thanks Jeremy, but what about inter-node communication?  If I have a user on node A sending a message to 10k users located on 10 other nodes, what is the best way to handle that?  Especially if this user is sending several messages and expecting replies.  Should I use the standard Erlang inter-process messaging or should I implement an MQ on top to handle this?
>
> Thanks,
> Lee
>
>
> On 11 Apr 2013, at 07:29, Jeremy Ong <jeremy at quarkgames.com> wrote:
>
>> Make all the machines identically and add an haproxy (or equivalent)
>> machine to load balance between all of them. Haproxy can handle many
>> many requests. Keep in mind that with tcp, the load balancer is just
>> accepting the socket but then the client communicates with the actual
>> application server directly afterwards.
>>
>> On Wed, Apr 10, 2013 at 10:51 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>>> Hi guys,
>>>
>>> So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.
>>>
>>> I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?
>>>
>>> Thanks,
>>> Lee
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>


From lee.sylvester at gmail.com  Thu Apr 11 14:55:29 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 11 Apr 2013 13:55:29 +0100
Subject: [99s-extend] Distributed model?
In-Reply-To: <CAKD1GY4xtZWXvfqstapnpLskbn3DFPPGDO9yHTLHDmTP+ozR7A@mail.gmail.com>
References: <[email protected]>
 <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>
 <[email protected]>
 <CAKD1GY4xtZWXvfqstapnpLskbn3DFPPGDO9yHTLHDmTP+ozR7A@mail.gmail.com>
Message-ID: <[email protected]>

Thank you, Jeremy, that's good advice.  It's not so much a chat platform, but I guess it would resemble one in architecture.  The part I'm concerned about, though, is should I be avoiding the internal Erlang messaging between connections (over many nodes) for heavy messaging?

Thanks,
Lee



On 11 Apr 2013, at 08:04, Jeremy Ong <jeremy at quarkgames.com> wrote:

> I see. I assume this is for a chat server of some sort?
> 
> You don't want the user process sending all these messages because the
> user process wouldn't be able to do anything useful (like receive
> messages) in the meantime.
> 
> Better is to implement a pubsub process for each channel of
> communication (i.e. one process per room) or rely on Redis pubsub or
> something if speed is extremely important.
> 
> There is no way to get around the O(N) complexity of broadcasting.
> 
> On Wed, Apr 10, 2013 at 11:49 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>> Thanks Jeremy, but what about inter-node communication?  If I have a user on node A sending a message to 10k users located on 10 other nodes, what is the best way to handle that?  Especially if this user is sending several messages and expecting replies.  Should I use the standard Erlang inter-process messaging or should I implement an MQ on top to handle this?
>> 
>> Thanks,
>> Lee
>> 
>> 
>> On 11 Apr 2013, at 07:29, Jeremy Ong <jeremy at quarkgames.com> wrote:
>> 
>>> Make all the machines identically and add an haproxy (or equivalent)
>>> machine to load balance between all of them. Haproxy can handle many
>>> many requests. Keep in mind that with tcp, the load balancer is just
>>> accepting the socket but then the client communicates with the actual
>>> application server directly afterwards.
>>> 
>>> On Wed, Apr 10, 2013 at 10:51 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>>>> Hi guys,
>>>> 
>>>> So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.
>>>> 
>>>> I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?
>>>> 
>>>> Thanks,
>>>> Lee
>>>> _______________________________________________
>>>> Extend mailing list
>>>> Extend at lists.ninenines.eu
>>>> http://lists.ninenines.eu:81/listinfo/extend
>> 



From lee.sylvester at gmail.com  Thu Apr 11 17:46:35 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Thu, 11 Apr 2013 16:46:35 +0100
Subject: [99s-extend] Distributed model?
In-Reply-To: <[email protected]>
References: <[email protected]>
 <CAKD1GY6z-Au5C-AsOus2ieOEtGymgigYp_SzGhrt+GgaXNFd=Q@mail.gmail.com>
 <[email protected]>
 <CAKD1GY4xtZWXvfqstapnpLskbn3DFPPGDO9yHTLHDmTP+ozR7A@mail.gmail.com>
 <[email protected]>
Message-ID: <[email protected]>

Okay, so I've figured it out.  I will need to have a separate messaging layer.  Does anyone know of a messaging layer that can be used when all you know is the PID to send to?

Thanks,
Lee



On 11 Apr 2013, at 13:55, Lee Sylvester <lee.sylvester at gmail.com> wrote:

> Thank you, Jeremy, that's good advice.  It's not so much a chat platform, but I guess it would resemble one in architecture.  The part I'm concerned about, though, is should I be avoiding the internal Erlang messaging between connections (over many nodes) for heavy messaging?
> 
> Thanks,
> Lee
> 
> 
> 
> On 11 Apr 2013, at 08:04, Jeremy Ong <jeremy at quarkgames.com> wrote:
> 
>> I see. I assume this is for a chat server of some sort?
>> 
>> You don't want the user process sending all these messages because the
>> user process wouldn't be able to do anything useful (like receive
>> messages) in the meantime.
>> 
>> Better is to implement a pubsub process for each channel of
>> communication (i.e. one process per room) or rely on Redis pubsub or
>> something if speed is extremely important.
>> 
>> There is no way to get around the O(N) complexity of broadcasting.
>> 
>> On Wed, Apr 10, 2013 at 11:49 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>>> Thanks Jeremy, but what about inter-node communication?  If I have a user on node A sending a message to 10k users located on 10 other nodes, what is the best way to handle that?  Especially if this user is sending several messages and expecting replies.  Should I use the standard Erlang inter-process messaging or should I implement an MQ on top to handle this?
>>> 
>>> Thanks,
>>> Lee
>>> 
>>> 
>>> On 11 Apr 2013, at 07:29, Jeremy Ong <jeremy at quarkgames.com> wrote:
>>> 
>>>> Make all the machines identically and add an haproxy (or equivalent)
>>>> machine to load balance between all of them. Haproxy can handle many
>>>> many requests. Keep in mind that with tcp, the load balancer is just
>>>> accepting the socket but then the client communicates with the actual
>>>> application server directly afterwards.
>>>> 
>>>> On Wed, Apr 10, 2013 at 10:51 PM, Lee Sylvester <lee.sylvester at gmail.com> wrote:
>>>>> Hi guys,
>>>>> 
>>>>> So, I have my Cowboy / Bullet server working nicely, now, with much thanks to members on this list.  I'm now looking at the best means of clustering this app.  I want to set this up so that, should the connection count get very high (which it will), then I should only have to throw more machines at this problem and it'll all go away.
>>>>> 
>>>>> I've got most of the logic working for this, but what I'm worried about is sending a lot of content over the erlang inter-node connection.  I've heard hogging this line can be both a bottleneck and can potentially interrupt the heartbeat between nodes.  With this in mind, should I look at adding a ZMQ layer or some such to facilitate this?  What is the general solution to high traffic between nodes?
>>>>> 
>>>>> Thanks,
>>>>> Lee
>>>>> _______________________________________________
>>>>> Extend mailing list
>>>>> Extend at lists.ninenines.eu
>>>>> http://lists.ninenines.eu:81/listinfo/extend
>>> 
> 



From Kevin.Brown at turner.com  Fri Apr 12 01:37:18 2013
From: Kevin.Brown at turner.com (Brown, Kevin)
Date: Thu, 11 Apr 2013 23:37:18 +0000
Subject: [99s-extend] populating #http_req for unit testing
In-Reply-To: <[email protected]>
Message-ID: <CD8CBFE1.A141%[email protected]>


Cowfolk,

I am doing something like this to create an #http_req suitable for unit
testing my resource callbacks:

-define (HTTP_REQ_ENCODERS_PORT_8000,  #http_req{host= <<"www.foo.com">> ,
port=8000, path= <<"/encoders">>,transport=ranch_tcp, qs= <<>>, fragment=
<<>> }).

Notice that I needed to set the transport to a Cowboy specific atom
because I wanted to get cowboy_req:host_url and cowboy_req:path to work
properly.  

I'm sure there is a method that Cowboy uses internally to populate an
#http_req from a URL that I could use for testing.  What might that be?
How else should I be populating this record.

Cheers,

-kb






On 4/11/13 7:07 PM, "extend-request at lists.ninenines.eu"
<extend-request at lists.ninenines.eu> wrote:

>Welcome to the Extend at lists.ninenines.eu mailing list!
>
>To post to this list, send your message to:
>
>  extend at lists.ninenines.eu
>
>General information about the mailing list is at:
>
>  http://lists.ninenines.eu:81/listinfo/extend
>
>If you ever want to unsubscribe or change your options (eg, switch to
>or from digest mode, change your password, etc.), visit your
>subscription page at:
>
>  http://lists.ninenines.eu:81/options/extend/kevin.brown%40turner.com
>
>You can also make such adjustments via email by sending a message to:
>
>  Extend-request at lists.ninenines.eu
>
>with the word `help' in the subject or body (don't include the
>quotes), and you will get back a message with instructions.
>
>You must know your password to change your options (including changing
>the password, itself) or to unsubscribe without confirmation.  It is:
>
>  doofus1
>
>Normally, Mailman will remind you of your lists.ninenines.eu mailing
>list passwords once every month, although you can disable this if you
>prefer.  This reminder will also include instructions on how to
>unsubscribe or change your account options.  There is also a button on
>your options page that will email your current password to you.
>




From essen at ninenines.eu  Fri Apr 12 02:07:26 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Fri, 12 Apr 2013 02:07:26 +0200
Subject: [99s-extend] populating #http_req for unit testing
In-Reply-To: <CD8CBFE1.A141%[email protected]>
References: <CD8CBFE1.A141%[email protected]>
Message-ID: <[email protected]>

There's a few undocumented functions in cowboy_req, like new, set and 
get, used by Cowboy internally.

On 04/12/2013 01:37 AM, Brown, Kevin wrote:
>
> Cowfolk,
>
> I am doing something like this to create an #http_req suitable for unit
> testing my resource callbacks:
>
> -define (HTTP_REQ_ENCODERS_PORT_8000,  #http_req{host= <<"www.foo.com">> ,
> port=8000, path= <<"/encoders">>,transport=ranch_tcp, qs= <<>>, fragment=
> <<>> }).
>
> Notice that I needed to set the transport to a Cowboy specific atom
> because I wanted to get cowboy_req:host_url and cowboy_req:path to work
> properly.
>
> I'm sure there is a method that Cowboy uses internally to populate an
> #http_req from a URL that I could use for testing.  What might that be?
> How else should I be populating this record.
>
> Cheers,
>
> -kb
>
>
>
>
>
>
> On 4/11/13 7:07 PM, "extend-request at lists.ninenines.eu"
> <extend-request at lists.ninenines.eu> wrote:
>
>> Welcome to the Extend at lists.ninenines.eu mailing list!
>>
>> To post to this list, send your message to:
>>
>>   extend at lists.ninenines.eu
>>
>> General information about the mailing list is at:
>>
>>   http://lists.ninenines.eu:81/listinfo/extend
>>
>> If you ever want to unsubscribe or change your options (eg, switch to
>> or from digest mode, change your password, etc.), visit your
>> subscription page at:
>>
>>   http://lists.ninenines.eu:81/options/extend/kevin.brown%40turner.com
>>
>> You can also make such adjustments via email by sending a message to:
>>
>>   Extend-request at lists.ninenines.eu
>>
>> with the word `help' in the subject or body (don't include the
>> quotes), and you will get back a message with instructions.
>>
>> You must know your password to change your options (including changing
>> the password, itself) or to unsubscribe without confirmation.  It is:
>>
>>   doofus1
>>
>> Normally, Mailman will remind you of your lists.ninenines.eu mailing
>> list passwords once every month, although you can disable this if you
>> prefer.  This reminder will also include instructions on how to
>> unsubscribe or change your account options.  There is also a button on
>> your options page that will email your current password to you.
>>
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From Kevin.Brown at turner.com  Fri Apr 12 02:30:15 2013
From: Kevin.Brown at turner.com (Brown, Kevin)
Date: Fri, 12 Apr 2013 00:30:15 +0000
Subject: [99s-extend] populating #http_req for unit testing
In-Reply-To: <[email protected]>
Message-ID: <CD8CCDCD.A1C9%[email protected]>

Thanks.

On 4/11/13 8:07 PM, "Lo?c Hoguin" <essen at ninenines.eu> wrote:

>There's a few undocumented functions in cowboy_req, like new, set and
>get, used by Cowboy internally.
>
>On 04/12/2013 01:37 AM, Brown, Kevin wrote:
>>
>> Cowfolk,
>>
>> I am doing something like this to create an #http_req suitable for unit
>> testing my resource callbacks:
>>
>> -define (HTTP_REQ_ENCODERS_PORT_8000,  #http_req{host=
>><<"www.foo.com">> ,
>> port=8000, path= <<"/encoders">>,transport=ranch_tcp, qs= <<>>,
>>fragment=
>> <<>> }).
>>
>> Notice that I needed to set the transport to a Cowboy specific atom
>> because I wanted to get cowboy_req:host_url and cowboy_req:path to work
>> properly.
>>
>> I'm sure there is a method that Cowboy uses internally to populate an
>> #http_req from a URL that I could use for testing.  What might that be?
>> How else should I be populating this record.
>>
>> Cheers,
>>
>> -kb
>>
>>
>>
>>
>>
>>
>> On 4/11/13 7:07 PM, "extend-request at lists.ninenines.eu"
>> <extend-request at lists.ninenines.eu> wrote:
>>
>>> Welcome to the Extend at lists.ninenines.eu mailing list!
>>>
>>> To post to this list, send your message to:
>>>
>>>   extend at lists.ninenines.eu
>>>
>>> General information about the mailing list is at:
>>>
>>>   http://lists.ninenines.eu:81/listinfo/extend
>>>
>>> If you ever want to unsubscribe or change your options (eg, switch to
>>> or from digest mode, change your password, etc.), visit your
>>> subscription page at:
>>>
>>>   http://lists.ninenines.eu:81/options/extend/kevin.brown%40turner.com
>>>
>>> You can also make such adjustments via email by sending a message to:
>>>
>>>   Extend-request at lists.ninenines.eu
>>>
>>> with the word `help' in the subject or body (don't include the
>>> quotes), and you will get back a message with instructions.
>>>
>>> You must know your password to change your options (including changing
>>> the password, itself) or to unsubscribe without confirmation.  It is:
>>>
>>>   doofus1
>>>
>>> Normally, Mailman will remind you of your lists.ninenines.eu mailing
>>> list passwords once every month, although you can disable this if you
>>> prefer.  This reminder will also include instructions on how to
>>> unsubscribe or change your account options.  There is also a button on
>>> your options page that will email your current password to you.
>>>
>>
>>
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>>
>
>
>-- 
>Lo?c Hoguin
>Erlang Cowboy
>Nine Nines
>http://ninenines.eu
>




From edgurgel at gmail.com  Sat Apr 13 13:12:39 2013
From: edgurgel at gmail.com (Eduardo Gurgel)
Date: Sat, 13 Apr 2013 08:12:39 -0300
Subject: [99s-extend] populating #http_req for unit testing
In-Reply-To: <CD8CBFE1.A141%[email protected]>
References: <[email protected]>
 <CD8CBFE1.A141%[email protected]>
Message-ID: <CAKAMJXjXrMs5OR+WfHwkmixGAx1UUP4-HyprhTffEjT4yXKBnA@mail.gmail.com>

On Thu, Apr 11, 2013 at 8:37 PM, Brown, Kevin <Kevin.Brown at turner.com>wrote:

>
> Cowfolk,
>
> I am doing something like this to create an #http_req suitable for unit
> testing my resource callbacks:
>


I use the library meck(https://github.com/eproxus/meck) to test stuff doing
something like this:

some_test() ->
  meck:expect(cowboy_req, binding, 2, {<<"app_key">>, req} )
  ?assertEqual({ok, req, empty},
                 websocket_handler:websocket_init(transport, req, opts)),
  ?assert(meck:validate(cowboy_req)).

I use simple atoms as input and mock the cowboy_req functions to return
atoms that would represent the correct or the wrong answer.

The real implementation or how cowboy represent stuff is not important
here, just the output pattern like {Binding, Req}.

That's it

-- 

Eduardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130413/f1b70800/attachment.html>

From erlang at rambocoder.com  Mon Apr 15 22:45:42 2013
From: erlang at rambocoder.com (rambocoder)
Date: Mon, 15 Apr 2013 16:45:42 -0400
Subject: [99s-extend] Reading body_qs multiple times
Message-ID: <CAJ0zLRN-62a9P7QhGz5q6qoj4WaWGv_4qzEznzzwb07Hqo-0QQ@mail.gmail.com>

Hello group,

I am trying to put together a CSRF middleware
https://github.com/rambocoder/stable/commit/b26980d292ac42aadfe9921a961436e28cdbb693
and
if the body of the request contains "_csrf" token, I check to make sure it
matches the csrf token in the session.

Currently I am doing it in middleware using cowboy_req:body_qs/1 however
when in the handler I need to read another body parameter, such as in the
rest_pastebin example:

{ok, BodyQs, Req3} = cowboy_req:body_qs(Req),
Paste = proplists:get_value(<<"paste">>, BodyQs),

cowboy_req:body_qs/1 returns [] due to the body of the request being
already read {body_state,done}

Is it pointless to have the type of CSRF middleware that I am writing and
just do the CSRF in the handler's callback, where I can deal with all the
body_qs at once?

Thank you,

rambocoder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130415/03f35a62/attachment.html>

From essen at ninenines.eu  Mon Apr 15 22:47:47 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Mon, 15 Apr 2013 22:47:47 +0200
Subject: [99s-extend] Reading body_qs multiple times
In-Reply-To: <CAJ0zLRN-62a9P7QhGz5q6qoj4WaWGv_4qzEznzzwb07Hqo-0QQ@mail.gmail.com>
References: <CAJ0zLRN-62a9P7QhGz5q6qoj4WaWGv_4qzEznzzwb07Hqo-0QQ@mail.gmail.com>
Message-ID: <[email protected]>

Why not just put the token in the URL instead? if it's CSRF then it's 
probably used only once and only for POST and the like, so not cached or 
anything.

On 04/15/2013 10:45 PM, rambocoder wrote:
> Hello group,
>
> I am trying to put together a CSRF middleware
> https://github.com/rambocoder/stable/commit/b26980d292ac42aadfe9921a961436e28cdbb693 and
> if the body of the request contains "_csrf" token, I check to make sure
> it matches the csrf token in the session.
>
> Currently I am doing it in middleware using cowboy_req:body_qs/1 however
> when in the handler I need to read another body parameter, such as in
> the rest_pastebin example:
>
> {ok, BodyQs, Req3} = cowboy_req:body_qs(Req),
> Paste = proplists:get_value(<<"paste">>, BodyQs),
>
> cowboy_req:body_qs/1 returns [] due to the body of the request being
> already read {body_state,done}
>
> Is it pointless to have the type of CSRF middleware that I am writing
> and just do the CSRF in the handler's callback, where I can deal with
> all the body_qs at once?
>
> Thank you,
>
> rambocoder
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From erlang at rambocoder.com  Tue Apr 16 02:13:44 2013
From: erlang at rambocoder.com (rambocoder)
Date: Mon, 15 Apr 2013 20:13:44 -0400
Subject: [99s-extend] Reading body_qs multiple times
In-Reply-To: <[email protected]>
References: <CAJ0zLRN-62a9P7QhGz5q6qoj4WaWGv_4qzEznzzwb07Hqo-0QQ@mail.gmail.com>
 <[email protected]>
Message-ID: <CAJ0zLRPYmtXEMd6G78D5Dc9-ebrdRzxyWmVHnzGE=YrH+hA6fg@mail.gmail.com>

Loic,

After giving the CSRF middleware some thought and reading
https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Disclosure_of_Token_in_URL
I
came to conclusion that it is best to just not create the middleware and
instead deal with CSRF on as needed basis.

I know that node's Connect middleware
http://www.senchalabs.org/connect/csrf.html#defaultValue for example allows
for the csrf token to be passed as a query string parameter, however, the
OWASP article made me think that it is not the most secure approach.

For example, AngularJS http://docs.angularjs.org/api/ng.$http has a section
on how their AJAX component behaves to do CSRF out of the box, and they are
talking about the server sending a cookie XSRF-TOKEN that is not HttpOnly.
That makes me realize that csrf is a process more than just slapping some
middleware into the pipeline.

Btw, I noticed that when the result of the middleware execute function is:
{error, StatusCode, Req}
if I set the reply on the request via cowboy_req:reply before returning the
{error.. , the status code of that reply will be used.

Such as:
{ok, Req3} = cowboy_req:reply(403, [], "Invalid CSRF Token.", Req2),
{error, 500, Req3}; % 500 is ignored, 403 is returned

Is that by design?

Sincerely,

rambocoder



On Mon, Apr 15, 2013 at 4:47 PM, Lo?c Hoguin <essen at ninenines.eu> wrote:

> Why not just put the token in the URL instead? if it's CSRF then it's
> probably used only once and only for POST and the like, so not cached or
> anything.
>
>
> On 04/15/2013 10:45 PM, rambocoder wrote:
>
>> Hello group,
>>
>> I am trying to put together a CSRF middleware
>> https://github.com/rambocoder/**stable/commit/**
>> b26980d292ac42aadfe9921a961436**e28cdbb693<https://github.com/rambocoder/stable/commit/b26980d292ac42aadfe9921a961436e28cdbb693>and
>> if the body of the request contains "_csrf" token, I check to make sure
>> it matches the csrf token in the session.
>>
>> Currently I am doing it in middleware using cowboy_req:body_qs/1 however
>> when in the handler I need to read another body parameter, such as in
>> the rest_pastebin example:
>>
>> {ok, BodyQs, Req3} = cowboy_req:body_qs(Req),
>> Paste = proplists:get_value(<<"paste">**>, BodyQs),
>>
>> cowboy_req:body_qs/1 returns [] due to the body of the request being
>> already read {body_state,done}
>>
>> Is it pointless to have the type of CSRF middleware that I am writing
>> and just do the CSRF in the handler's callback, where I can deal with
>> all the body_qs at once?
>>
>> Thank you,
>>
>> rambocoder
>>
>>
>> ______________________________**_________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/**listinfo/extend<http://lists.ninenines.eu:81/listinfo/extend>
>>
>>
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130415/59aaeef2/attachment.html>

From essen at ninenines.eu  Tue Apr 16 13:34:14 2013
From: essen at ninenines.eu (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=)
Date: Tue, 16 Apr 2013 13:34:14 +0200
Subject: [99s-extend] Reading body_qs multiple times
In-Reply-To: <CAJ0zLRPYmtXEMd6G78D5Dc9-ebrdRzxyWmVHnzGE=YrH+hA6fg@mail.gmail.com>
References: <CAJ0zLRN-62a9P7QhGz5q6qoj4WaWGv_4qzEznzzwb07Hqo-0QQ@mail.gmail.com>
 <[email protected]>
 <CAJ0zLRPYmtXEMd6G78D5Dc9-ebrdRzxyWmVHnzGE=YrH+hA6fg@mail.gmail.com>
Message-ID: <[email protected]>

On 04/16/2013 02:13 AM, rambocoder wrote:
> Loic,
>
> After giving the CSRF middleware some thought and reading
> https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Disclosure_of_Token_in_URL I
> came to conclusion that it is best to just not create the middleware and
> instead deal with CSRF on as needed basis.

Your link says what I said too, except I probably wasn't explicit enough.

If you have a form that does POST (or PUT or PATCH or DELETE), put the 
token in "<form action="/path/to/resource?csrf=$TOKEN">". The token must 
be only valid once, it must not be reused, not even between different 
forms (each form gets its own token). Since it is not a GET request, 
then you don't have cache or referer issues.

You can still have issues if you allow another site to run JS on yours 
(but you probably shouldn't) or if there is a malevolent proxy (use SSL 
where needed), but these are different issues entirely.

> Btw, I noticed that when the result of the middleware execute function is:
> {error, StatusCode, Req}
> if I set the reply on the request via cowboy_req:reply before returning
> the {error.. , the status code of that reply will be used.
>
> Such as:
> {ok, Req3} = cowboy_req:reply(403, [], "Invalid CSRF Token.", Req2),
> {error, 500, Req3}; % 500 is ignored, 403 is returned

Yes, the response was already sent, therefore the second one is ignored.

> Is that by design?
>
> Sincerely,
>
> rambocoder
>
>
>
> On Mon, Apr 15, 2013 at 4:47 PM, Lo?c Hoguin <essen at ninenines.eu
> <mailto:essen at ninenines.eu>> wrote:
>
>     Why not just put the token in the URL instead? if it's CSRF then
>     it's probably used only once and only for POST and the like, so not
>     cached or anything.
>
>
>     On 04/15/2013 10:45 PM, rambocoder wrote:
>
>         Hello group,
>
>         I am trying to put together a CSRF middleware
>         https://github.com/rambocoder/__stable/commit/__b26980d292ac42aadfe9921a961436__e28cdbb693
>         <https://github.com/rambocoder/stable/commit/b26980d292ac42aadfe9921a961436e28cdbb693>
>         and
>         if the body of the request contains "_csrf" token, I check to
>         make sure
>         it matches the csrf token in the session.
>
>         Currently I am doing it in middleware using cowboy_req:body_qs/1
>         however
>         when in the handler I need to read another body parameter, such
>         as in
>         the rest_pastebin example:
>
>         {ok, BodyQs, Req3} = cowboy_req:body_qs(Req),
>         Paste = proplists:get_value(<<"paste">__>, BodyQs),
>
>         cowboy_req:body_qs/1 returns [] due to the body of the request being
>         already read {body_state,done}
>
>         Is it pointless to have the type of CSRF middleware that I am
>         writing
>         and just do the CSRF in the handler's callback, where I can deal
>         with
>         all the body_qs at once?
>
>         Thank you,
>
>         rambocoder
>
>
>         _________________________________________________
>         Extend mailing list
>         Extend at lists.ninenines.eu <mailto:Extend at lists.ninenines.eu>
>         http://lists.ninenines.eu:81/__listinfo/extend
>         <http://lists.ninenines.eu:81/listinfo/extend>
>
>
>
>     --
>     Lo?c Hoguin
>     Erlang Cowboy
>     Nine Nines
>     http://ninenines.eu
>
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From lee.sylvester at gmail.com  Fri Apr 19 16:47:09 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Fri, 19 Apr 2013 15:47:09 +0100
Subject: [99s-extend] Cowboy CORS
Message-ID: <[email protected]>

Hi guys,

So, I thought I had this resolved, as I managed to get it working locally, but across different local domains (test.localhost.com and cowboy.localhost.com).  However, now I've deployed my app to a VM, I simply can't get CORS working in Cowboy.  Here's the OPTIONS response from Chrome's console:


Request URL:http://www.example.com/
Request Method:OPTIONS
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, method, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:www.example.com
Origin:http://test.localhost.com:8889
Referer:http://test.localhost.com:8889/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
Response Headersview source
Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin, Method
Access-Control-Allow-Methods:GET, POST, OPTIONS
Access-Control-Allow-Origin:*
connection:keep-alive
content-length:0
date:Fri, 19 Apr 2013 14:40:00 GMT
server:Cowboy

And then this is the POST response:

Request URL:http://www.example.com/
Request Headersview parsed
POST http://www.example.com/ HTTP/1.1
Origin: http://test.localhost.com:8889
Referer: http://test.localhost.com:8889/
method: POST http://www.example.com/ HTTP/1.1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
content-type: application/x-www-form-urlencoded
Form Dataview parsed
data={"Type":"auth_request","Authentication":"public","Authorization":null,"Domain":"www.example.com","Application":"test_app","Ident":"lee"}

I am setting {<<"Access-Control-Allow-Origin">>, <<"*">>} in the headers param of cowboy_req:reply and the cowboy_req:set_resp_header, but neither seems to be working.  Can anyone spot what I might be doing wrong?

The cowboy_req:set_resp_header is happening in the handle? So

handle(Req, State) ->
	Reply = case cowboy_req:method(Req) of
		{<<"POST">>, Req2} ->
			Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
[snip]


Thanks,
Lee

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130419/bf0e8ef9/attachment.html>

From Christopher.Phillips at turner.com  Fri Apr 19 17:08:03 2013
From: Christopher.Phillips at turner.com (Phillips, Christopher)
Date: Fri, 19 Apr 2013 15:08:03 +0000
Subject: [99s-extend] Cowboy CORS
In-Reply-To: <[email protected]>
Message-ID: <CD96D43A.4E43%[email protected]>

  When querying to the VM from a browser, is Chrome complaining that it's a cross domain request in the console? Or something else?

  Is the OPTIONS request firing and failing, or is it the POST that is failing (in the network tab)?

  If it's working in a cross origin context for you locally across different domains (I.e., the browser is sending the CORS headers on the request, and you're seeing the right headers on the response, and the browser is handling them properly, such that you can retrieve the response from your Javascript), then it seems unlikely to be a CORS issue, but maybe a config or proxy or code issue in your handler.


From: Lee Sylvester <lee.sylvester at gmail.com<mailto:lee.sylvester at gmail.com>>
Date: Friday, April 19, 2013 10:47 AM
To: "extend at lists.ninenines.eu<mailto:extend at lists.ninenines.eu>" <extend at lists.ninenines.eu<mailto:extend at lists.ninenines.eu>>
Subject: [99s-extend] Cowboy CORS

Hi guys,

So, I thought I had this resolved, as I managed to get it working locally, but across different local domains (test.localhost.com<http://test.localhost.com> and cowboy.localhost.com<http://cowboy.localhost.com>).  However, now I've deployed my app to a VM, I simply can't get CORS working in Cowboy.  Here's the OPTIONS response from Chrome's console:



  1.
Request URL:
http://www.example.com/
  2.
Request Method:
OPTIONS
  3.
Status Code:
200 OK
  4.  Request Headersview source
     *
Accept:
*/*
     *
Accept-Charset:
ISO-8859-1,utf-8;q=0.7,*;q=0.3
     *
Accept-Encoding:
gzip,deflate,sdch
     *
Accept-Language:
en-US,en;q=0.8
     *
Access-Control-Request-Headers:
origin, method, content-type
     *
Access-Control-Request-Method:
POST
     *
Connection:
keep-alive
     *
Host:
www.example.com<http://www.example.com>
     *
Origin:
http://test.localhost.com:8889
     *
Referer:
http://test.localhost.com:8889/
     *
User-Agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
  5.  Response Headersview source
     *
Access-Control-Allow-Headers:
Content-Type, X-Requested-With, Origin, Method
     *
Access-Control-Allow-Methods:
GET, POST, OPTIONS
     *
Access-Control-Allow-Origin:
*
     *
connection:
keep-alive
     *
content-length:
0
     *
date:
Fri, 19 Apr 2013 14:40:00 GMT
     *
server:
Cowboy

And then this is the POST response:


  1.
Request URL:
http://www.example.com/
  2.  Request Headersview parsed
     *   POST http://www.example.com/ HTTP/1.1 Origin: http://test.localhost.com:8889 Referer: http://test.localhost.com:8889/ method: POST http://www.example.com/ HTTP/1.1 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31 content-type: application/x-www-form-urlencoded
  3.  Form Dataview parsed
     *   data={"Type":"auth_request","Authentication":"public","Authorization":null,"Domain":"www.example.com<http://www.example.com>","Application":"test_app","Ident":"lee"}

I am setting {<<"Access-Control-Allow-Origin">>, <<"*">>} in the headers param of cowboy_req:reply and the cowboy_req:set_resp_header, but neither seems to be working.  Can anyone spot what I might be doing wrong?

The cowboy_req:set_resp_header is happening in the handle? So

handle(Req, State) ->
Reply = case cowboy_req:method(Req) of
{<<"POST">>, Req2} ->
Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req2),
[snip]


Thanks,
Lee

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130419/383515dd/attachment.html>

From lee.sylvester at gmail.com  Mon Apr 22 14:59:54 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Mon, 22 Apr 2013 13:59:54 +0100
Subject: [99s-extend] 505 error
Message-ID: <[email protected]>

Hi guys,

So, I was getting a CORS issue when connecting to my Bullet impl, which I have since fixed.  I am now able to use these from many machines from many locations.  However, I have found some machines to be getting a 505 error when making a POST request to the Cowboy instance:

Request URL:http://www.example.com
Request Method:OPTIONS
Status Code:505 HTTP Version Not Supported
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, method, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:www.example.com
Origin:http://www.test.com
Referer:http://www.test.com/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Response Headersview source
connection:close
content-length:0
date:Mon, 22 Apr 2013 12:22:50 GMT
server:Cowboy

To get around the CORS issue, I set up an onrequest hook, which points to the function:

set_request_cors(Req) ->
	Req2 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET, POST, OPTIONS">>, Req),
	Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>, <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
	cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req3).

I'm afraid I don't have any more info, but this issue is completely eluding me.

Thanks,
Lee



From Kevin.Brown at turner.com  Mon Apr 22 16:28:11 2013
From: Kevin.Brown at turner.com (Brown, Kevin)
Date: Mon, 22 Apr 2013 14:28:11 +0000
Subject: [99s-extend] 505 error
In-Reply-To: <[email protected]>
References: <[email protected]>
Message-ID: <[email protected]>

What is the exact http request sent on the failing and successful machines?  How do the differ?

Stack trace?

On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:

> Hi guys,
> 
> So, I was getting a CORS issue when connecting to my Bullet impl, which I have since fixed.  I am now able to use these from many machines from many locations.  However, I have found some machines to be getting a 505 error when making a POST request to the Cowboy instance:
> 
> Request URL:http://www.example.com
> Request Method:OPTIONS
> Status Code:505 HTTP Version Not Supported
> Request Headersview source
> Accept:*/*
> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
> Accept-Encoding:gzip,deflate,sdch
> Accept-Language:en-US,en;q=0.8
> Access-Control-Request-Headers:origin, method, content-type
> Access-Control-Request-Method:POST
> Connection:keep-alive
> Host:www.example.com
> Origin:http://www.test.com
> Referer:http://www.test.com/
> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
> Response Headersview source
> connection:close
> content-length:0
> date:Mon, 22 Apr 2013 12:22:50 GMT
> server:Cowboy
> 
> To get around the CORS issue, I set up an onrequest hook, which points to the function:
> 
> set_request_cors(Req) ->
>    Req2 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET, POST, OPTIONS">>, Req),
>    Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>, <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>    cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req3).
> 
> I'm afraid I don't have any more info, but this issue is completely eluding me.
> 
> Thanks,
> Lee
> 
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
> 



From lee.sylvester at gmail.com  Mon Apr 22 16:40:19 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Mon, 22 Apr 2013 15:40:19 +0100
Subject: [99s-extend] 505 error
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Well, the below is the sent and return headers on the failing machine.  On a succeeding machine, the headers are

Request URL:http://www.example.com
Request Method:OPTIONS
Status Code:200 OK

Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Access-Control-Request-Headers:origin, method, content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:www.example.com
Origin:http://www.test.com
Referer:http://www.test.com/
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31

Response Headersview source
Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin, Method
Access-Control-Allow-Methods:GET, POST, OPTIONS
Access-Control-Allow-Origin:*
connection:keep-alive
content-length:68
date:Mon, 22 Apr 2013 14:33:30 GMT
server:Cowboy

As you can see, the header control and content isn't being sent back and the connection is closed.

Thanks,
Lee




On 22 Apr 2013, at 15:28, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:

> What is the exact http request sent on the failing and successful machines?  How do the differ?
> 
> Stack trace?
> 
> On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:
> 
>> Hi guys,
>> 
>> So, I was getting a CORS issue when connecting to my Bullet impl, which I have since fixed.  I am now able to use these from many machines from many locations.  However, I have found some machines to be getting a 505 error when making a POST request to the Cowboy instance:
>> 
>> Request URL:http://www.example.com
>> Request Method:OPTIONS
>> Status Code:505 HTTP Version Not Supported
>> 
>> Request Headersview source
>> Accept:*/*
>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>> Accept-Encoding:gzip,deflate,sdch
>> Accept-Language:en-US,en;q=0.8
>> Access-Control-Request-Headers:origin, method, content-type
>> Access-Control-Request-Method:POST
>> Connection:keep-alive
>> Host:www.example.com
>> Origin:http://www.test.com
>> Referer:http://www.test.com/
>> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
>> 
>> Response Headersview source
>> connection:close
>> content-length:0
>> date:Mon, 22 Apr 2013 12:22:50 GMT
>> server:Cowboy
>> 
>> To get around the CORS issue, I set up an onrequest hook, which points to the function:
>> 
>> set_request_cors(Req) ->
>>   Req2 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET, POST, OPTIONS">>, Req),
>>   Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>, <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>>   cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req3).
>> 
>> I'm afraid I don't have any more info, but this issue is completely eluding me.
>> 
>> Thanks,
>> Lee
>> 
>> _______________________________________________
>> Extend mailing list
>> Extend at lists.ninenines.eu
>> http://lists.ninenines.eu:81/listinfo/extend
>> 
> 



From essen at ninenines.eu  Mon Apr 22 17:53:44 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Mon, 22 Apr 2013 17:53:44 +0200
Subject: [99s-extend] 505 error
In-Reply-To: <[email protected]>
References: <[email protected]>
 <[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

Headers are one thing but it'd be useful to know the request line itself.

On 04/22/2013 04:40 PM, Lee Sylvester wrote:
> Well, the below is the sent and return headers on the failing machine.  On a succeeding machine, the headers are
>
> Request URL:http://www.example.com
> Request Method:OPTIONS
> Status Code:200 OK
>
> Request Headersview source
> Accept:*/*
> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
> Accept-Encoding:gzip,deflate,sdch
> Accept-Language:en-US,en;q=0.8
> Access-Control-Request-Headers:origin, method, content-type
> Access-Control-Request-Method:POST
> Connection:keep-alive
> Host:www.example.com
> Origin:http://www.test.com
> Referer:http://www.test.com/
> User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
>
> Response Headersview source
> Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin, Method
> Access-Control-Allow-Methods:GET, POST, OPTIONS
> Access-Control-Allow-Origin:*
> connection:keep-alive
> content-length:68
> date:Mon, 22 Apr 2013 14:33:30 GMT
> server:Cowboy
>
> As you can see, the header control and content isn't being sent back and the connection is closed.
>
> Thanks,
> Lee
>
>
>
>
> On 22 Apr 2013, at 15:28, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:
>
>> What is the exact http request sent on the failing and successful machines?  How do the differ?
>>
>> Stack trace?
>>
>> On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:
>>
>>> Hi guys,
>>>
>>> So, I was getting a CORS issue when connecting to my Bullet impl, which I have since fixed.  I am now able to use these from many machines from many locations.  However, I have found some machines to be getting a 505 error when making a POST request to the Cowboy instance:
>>>
>>> Request URL:http://www.example.com
>>> Request Method:OPTIONS
>>> Status Code:505 HTTP Version Not Supported
>>>
>>> Request Headersview source
>>> Accept:*/*
>>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>>> Accept-Encoding:gzip,deflate,sdch
>>> Accept-Language:en-US,en;q=0.8
>>> Access-Control-Request-Headers:origin, method, content-type
>>> Access-Control-Request-Method:POST
>>> Connection:keep-alive
>>> Host:www.example.com
>>> Origin:http://www.test.com
>>> Referer:http://www.test.com/
>>> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
>>>
>>> Response Headersview source
>>> connection:close
>>> content-length:0
>>> date:Mon, 22 Apr 2013 12:22:50 GMT
>>> server:Cowboy
>>>
>>> To get around the CORS issue, I set up an onrequest hook, which points to the function:
>>>
>>> set_request_cors(Req) ->
>>>    Req2 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET, POST, OPTIONS">>, Req),
>>>    Req3 = cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>, <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>>>    cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>, <<"*">>, Req3).
>>>
>>> I'm afraid I don't have any more info, but this issue is completely eluding me.
>>>
>>> Thanks,
>>> Lee
>>>
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>>>
>>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From Kevin.Brown at turner.com  Mon Apr 22 17:55:11 2013
From: Kevin.Brown at turner.com (Brown, Kevin)
Date: Mon, 22 Apr 2013 15:55:11 +0000
Subject: [99s-extend] 505 error
In-Reply-To: <[email protected]>
Message-ID: <CD9AD247.AB02%[email protected]>

You might see if "view source" (rather than the parsed view you sent)
yields any clues.  You'd like to see HTTP version being sent.


On 4/22/13 10:40 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:

>Well, the below is the sent and return headers on the failing machine.
>On a succeeding machine, the headers are
>
>Request URL:http://www.example.com
>Request Method:OPTIONS
>Status Code:200 OK
>
>Request Headersview source
>Accept:*/*
>Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>Accept-Encoding:gzip,deflate,sdch
>Accept-Language:en-US,en;q=0.8
>Access-Control-Request-Headers:origin, method, content-type
>Access-Control-Request-Method:POST
>Connection:keep-alive
>Host:www.example.com
>Origin:http://www.test.com
>Referer:http://www.test.com/
>User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
>AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
>
>Response Headersview source
>Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin,
>Method
>Access-Control-Allow-Methods:GET, POST, OPTIONS
>Access-Control-Allow-Origin:*
>connection:keep-alive
>content-length:68
>date:Mon, 22 Apr 2013 14:33:30 GMT
>server:Cowboy
>
>As you can see, the header control and content isn't being sent back and
>the connection is closed.
>
>Thanks,
>Lee
>
>
>
>
>On 22 Apr 2013, at 15:28, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:
>
>> What is the exact http request sent on the failing and successful
>>machines?  How do the differ?
>> 
>> Stack trace?
>> 
>> On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com>
>>wrote:
>> 
>>> Hi guys,
>>> 
>>> So, I was getting a CORS issue when connecting to my Bullet impl,
>>>which I have since fixed.  I am now able to use these from many
>>>machines from many locations.  However, I have found some machines to
>>>be getting a 505 error when making a POST request to the Cowboy
>>>instance:
>>> 
>>> Request URL:http://www.example.com
>>> Request Method:OPTIONS
>>> Status Code:505 HTTP Version Not Supported
>>> 
>>> Request Headersview source
>>> Accept:*/*
>>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>>> Accept-Encoding:gzip,deflate,sdch
>>> Accept-Language:en-US,en;q=0.8
>>> Access-Control-Request-Headers:origin, method, content-type
>>> Access-Control-Request-Method:POST
>>> Connection:keep-alive
>>> Host:www.example.com
>>> Origin:http://www.test.com
>>> Referer:http://www.test.com/
>>> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31
>>>(KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
>>> 
>>> Response Headersview source
>>> connection:close
>>> content-length:0
>>> date:Mon, 22 Apr 2013 12:22:50 GMT
>>> server:Cowboy
>>> 
>>> To get around the CORS issue, I set up an onrequest hook, which points
>>>to the function:
>>> 
>>> set_request_cors(Req) ->
>>>   Req2 = 
>>>cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET,
>>>POST, OPTIONS">>, Req),
>>>   Req3 = 
>>>cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>,
>>><<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>>>   cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>,
>>><<"*">>, Req3).
>>> 
>>> I'm afraid I don't have any more info, but this issue is completely
>>>eluding me.
>>> 
>>> Thanks,
>>> Lee
>>> 
>>> _______________________________________________
>>> Extend mailing list
>>> Extend at lists.ninenines.eu
>>> http://lists.ninenines.eu:81/listinfo/extend
>>> 
>> 
>
>




From lee.sylvester at gmail.com  Mon Apr 22 20:30:08 2013
From: lee.sylvester at gmail.com (Lee Sylvester)
Date: Mon, 22 Apr 2013 19:30:08 +0100
Subject: [99s-extend] 505 error
In-Reply-To: <CD9AD247.AB02%[email protected]>
References: <CD9AD247.AB02%[email protected]>
Message-ID: <[email protected]>

Does this help?

Request URL:http://www.example.com
Request Method:OPTIONS
Status Code:505 HTTP Version Not Supported

Request Headersview parsed
OPTIONS http://www.example.com HTTP/1.1
Host: www.example.com
Proxy-Connection: keep-alive
Access-Control-Request-Method: POST
Origin: http://localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
Access-Control-Request-Headers: origin, method, content-type
Accept: */*
Referer: http://localhost/p/
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

Response Headersview parsed
HTTP/1.1 505 HTTP Version Not Supported
connection: close
server: Cowboy
date: Mon, 22 Apr 2013 17:42:39 GMT
content-length: 0

Thanks,
Lee


On 22 Apr 2013, at 16:55, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:

> You might see if "view source" (rather than the parsed view you sent)
> yields any clues.  You'd like to see HTTP version being sent.
> 
> 
> On 4/22/13 10:40 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:
> 
>> Well, the below is the sent and return headers on the failing machine.
>> On a succeeding machine, the headers are
>> 
>> Request URL:http://www.example.com
>> Request Method:OPTIONS
>> Status Code:200 OK
>> 
>> Request Headersview source
>> Accept:*/*
>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>> Accept-Encoding:gzip,deflate,sdch
>> Accept-Language:en-US,en;q=0.8
>> Access-Control-Request-Headers:origin, method, content-type
>> Access-Control-Request-Method:POST
>> Connection:keep-alive
>> Host:www.example.com
>> Origin:http://www.test.com
>> Referer:http://www.test.com/
>> User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
>> AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
>> 
>> Response Headersview source
>> Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin,
>> Method
>> Access-Control-Allow-Methods:GET, POST, OPTIONS
>> Access-Control-Allow-Origin:*
>> connection:keep-alive
>> content-length:68
>> date:Mon, 22 Apr 2013 14:33:30 GMT
>> server:Cowboy
>> 
>> As you can see, the header control and content isn't being sent back and
>> the connection is closed.
>> 
>> Thanks,
>> Lee
>> 
>> 
>> 
>> 
>> On 22 Apr 2013, at 15:28, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:
>> 
>>> What is the exact http request sent on the failing and successful
>>> machines?  How do the differ?
>>> 
>>> Stack trace?
>>> 
>>> On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com>
>>> wrote:
>>> 
>>>> Hi guys,
>>>> 
>>>> So, I was getting a CORS issue when connecting to my Bullet impl,
>>>> which I have since fixed.  I am now able to use these from many
>>>> machines from many locations.  However, I have found some machines to
>>>> be getting a 505 error when making a POST request to the Cowboy
>>>> instance:
>>>> 
>>>> Request URL:http://www.example.com
>>>> Request Method:OPTIONS
>>>> Status Code:505 HTTP Version Not Supported
>>>> 
>>>> Request Headersview source
>>>> Accept:*/*
>>>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>>>> Accept-Encoding:gzip,deflate,sdch
>>>> Accept-Language:en-US,en;q=0.8
>>>> Access-Control-Request-Headers:origin, method, content-type
>>>> Access-Control-Request-Method:POST
>>>> Connection:keep-alive
>>>> Host:www.example.com
>>>> Origin:http://www.test.com
>>>> Referer:http://www.test.com/
>>>> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31
>>>> (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
>>>> 
>>>> Response Headersview source
>>>> connection:close
>>>> content-length:0
>>>> date:Mon, 22 Apr 2013 12:22:50 GMT
>>>> server:Cowboy
>>>> 
>>>> To get around the CORS issue, I set up an onrequest hook, which points
>>>> to the function:
>>>> 
>>>> set_request_cors(Req) ->
>>>>  Req2 = 
>>>> cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET,
>>>> POST, OPTIONS">>, Req),
>>>>  Req3 = 
>>>> cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>,
>>>> <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>>>>  cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>,
>>>> <<"*">>, Req3).
>>>> 
>>>> I'm afraid I don't have any more info, but this issue is completely
>>>> eluding me.
>>>> 
>>>> Thanks,
>>>> Lee
>>>> 
>>>> _______________________________________________
>>>> Extend mailing list
>>>> Extend at lists.ninenines.eu
>>>> http://lists.ninenines.eu:81/listinfo/extend
>>>> 
>>> 
>> 
>> 
> 
> 



From essen at ninenines.eu  Mon Apr 22 21:19:39 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Mon, 22 Apr 2013 21:19:39 +0200
Subject: [99s-extend] 505 error
In-Reply-To: <[email protected]>
References: <CD9AD247.AB02%[email protected]>
 <[email protected]>
Message-ID: <[email protected]>

I'm going to need the exact request line to make sense of it. 
Something's missing in the parser I think, not sure what in your case 
though. Feel free to private email it.

On 04/22/2013 08:30 PM, Lee Sylvester wrote:
> Does this help?
>
> Request URL:http://www.example.com
> Request Method:OPTIONS
> Status Code:505 HTTP Version Not Supported
>
> Request Headersview parsed
> OPTIONS http://www.example.com HTTP/1.1
> Host: www.example.com
> Proxy-Connection: keep-alive
> Access-Control-Request-Method: POST
> Origin: http://localhost
> User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
> Access-Control-Request-Headers: origin, method, content-type
> Accept: */*
> Referer: http://localhost/p/
> Accept-Encoding: gzip,deflate,sdch
> Accept-Language: en-US,en;q=0.8
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
>
> Response Headersview parsed
> HTTP/1.1 505 HTTP Version Not Supported
> connection: close
> server: Cowboy
> date: Mon, 22 Apr 2013 17:42:39 GMT
> content-length: 0
>
> Thanks,
> Lee
>
>
> On 22 Apr 2013, at 16:55, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:
>
>> You might see if "view source" (rather than the parsed view you sent)
>> yields any clues.  You'd like to see HTTP version being sent.
>>
>>
>> On 4/22/13 10:40 AM, "Lee Sylvester" <lee.sylvester at gmail.com> wrote:
>>
>>> Well, the below is the sent and return headers on the failing machine.
>>> On a succeeding machine, the headers are
>>>
>>> Request URL:http://www.example.com
>>> Request Method:OPTIONS
>>> Status Code:200 OK
>>>
>>> Request Headersview source
>>> Accept:*/*
>>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>>> Accept-Encoding:gzip,deflate,sdch
>>> Accept-Language:en-US,en;q=0.8
>>> Access-Control-Request-Headers:origin, method, content-type
>>> Access-Control-Request-Method:POST
>>> Connection:keep-alive
>>> Host:www.example.com
>>> Origin:http://www.test.com
>>> Referer:http://www.test.com/
>>> User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3)
>>> AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31
>>>
>>> Response Headersview source
>>> Access-Control-Allow-Headers:Content-Type, X-Requested-With, Origin,
>>> Method
>>> Access-Control-Allow-Methods:GET, POST, OPTIONS
>>> Access-Control-Allow-Origin:*
>>> connection:keep-alive
>>> content-length:68
>>> date:Mon, 22 Apr 2013 14:33:30 GMT
>>> server:Cowboy
>>>
>>> As you can see, the header control and content isn't being sent back and
>>> the connection is closed.
>>>
>>> Thanks,
>>> Lee
>>>
>>>
>>>
>>>
>>> On 22 Apr 2013, at 15:28, "Brown, Kevin" <Kevin.Brown at turner.com> wrote:
>>>
>>>> What is the exact http request sent on the failing and successful
>>>> machines?  How do the differ?
>>>>
>>>> Stack trace?
>>>>
>>>> On Apr 22, 2013, at 9:00 AM, "Lee Sylvester" <lee.sylvester at gmail.com>
>>>> wrote:
>>>>
>>>>> Hi guys,
>>>>>
>>>>> So, I was getting a CORS issue when connecting to my Bullet impl,
>>>>> which I have since fixed.  I am now able to use these from many
>>>>> machines from many locations.  However, I have found some machines to
>>>>> be getting a 505 error when making a POST request to the Cowboy
>>>>> instance:
>>>>>
>>>>> Request URL:http://www.example.com
>>>>> Request Method:OPTIONS
>>>>> Status Code:505 HTTP Version Not Supported
>>>>>
>>>>> Request Headersview source
>>>>> Accept:*/*
>>>>> Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
>>>>> Accept-Encoding:gzip,deflate,sdch
>>>>> Accept-Language:en-US,en;q=0.8
>>>>> Access-Control-Request-Headers:origin, method, content-type
>>>>> Access-Control-Request-Method:POST
>>>>> Connection:keep-alive
>>>>> Host:www.example.com
>>>>> Origin:http://www.test.com
>>>>> Referer:http://www.test.com/
>>>>> User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31
>>>>> (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31
>>>>>
>>>>> Response Headersview source
>>>>> connection:close
>>>>> content-length:0
>>>>> date:Mon, 22 Apr 2013 12:22:50 GMT
>>>>> server:Cowboy
>>>>>
>>>>> To get around the CORS issue, I set up an onrequest hook, which points
>>>>> to the function:
>>>>>
>>>>> set_request_cors(Req) ->
>>>>>   Req2 =
>>>>> cowboy_req:set_resp_header(<<"Access-Control-Allow-Methods">>, <<"GET,
>>>>> POST, OPTIONS">>, Req),
>>>>>   Req3 =
>>>>> cowboy_req:set_resp_header(<<"Access-Control-Allow-Headers">>,
>>>>> <<"Content-Type, X-Requested-With, Origin, Method">>, Req2),
>>>>>   cowboy_req:set_resp_header(<<"Access-Control-Allow-Origin">>,
>>>>> <<"*">>, Req3).
>>>>>
>>>>> I'm afraid I don't have any more info, but this issue is completely
>>>>> eluding me.
>>>>>
>>>>> Thanks,
>>>>> Lee
>>>>>
>>>>> _______________________________________________
>>>>> Extend mailing list
>>>>> Extend at lists.ninenines.eu
>>>>> http://lists.ninenines.eu:81/listinfo/extend
>>>>>
>>>>
>>>
>>>
>>
>>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>


-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From yongboy at gmail.com  Thu Apr 25 05:46:24 2013
From: yongboy at gmail.com (yongboy)
Date: Thu, 25 Apr 2013 11:46:24 +0800
Subject: [99s-extend] does cowboy support hot code reload/replace ?
Message-ID: <CAN_mQBqbjr_JzSoL=YOzM8SaMbmvd=_OJ5FMg-DbYgKeYq6hBA@mail.gmail.com>

You know, the OTP's code_change so heavy, sometimes, you just want to
debug, or change a little, does not want to rewrite the rel appup file.
Any help is appreciated, thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130425/35ee7614/attachment.html>

From essen at ninenines.eu  Thu Apr 25 13:42:15 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Thu, 25 Apr 2013 13:42:15 +0200
Subject: [99s-extend] does cowboy support hot code reload/replace ?
In-Reply-To: <CAN_mQBqbjr_JzSoL=YOzM8SaMbmvd=_OJ5FMg-DbYgKeYq6hBA@mail.gmail.com>
References: <CAN_mQBqbjr_JzSoL=YOzM8SaMbmvd=_OJ5FMg-DbYgKeYq6hBA@mail.gmail.com>
Message-ID: <[email protected]>

On 04/25/2013 05:46 AM, yongboy wrote:
> You know, the OTP's code_change so heavy, sometimes, you just want to
> debug, or change a little, does not want to rewrite the rel appup file.
> Any help is appreciated, thanks.

At this time there is no code_change mechanism in Cowboy. Reloading a 
module works, modifying the protocol options with 
ranch:set_protocol_options can be used, but it doesn't change the 
running processes.

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From yongboy at gmail.com  Fri Apr 26 07:57:00 2013
From: yongboy at gmail.com (yongboy)
Date: Fri, 26 Apr 2013 13:57:00 +0800
Subject: [99s-extend] does cowboy support hot code reload/replace ?
In-Reply-To: <[email protected]>
References: <CAN_mQBqbjr_JzSoL=YOzM8SaMbmvd=_OJ5FMg-DbYgKeYq6hBA@mail.gmail.com>
 <[email protected]>
Message-ID: <CAN_mQBq4FEG66Ot2CpTLgChaaTMUW1vG0cjsZrEs-Rbms7zGuQ@mail.gmail.com>

Thanks very much !
Maybe we can use the code:load_file() function I had just found it .


2013/4/25 Lo?c Hoguin <essen at ninenines.eu>

> On 04/25/2013 05:46 AM, yongboy wrote:
>
>> You know, the OTP's code_change so heavy, sometimes, you just want to
>> debug, or change a little, does not want to rewrite the rel appup file.
>> Any help is appreciated, thanks.
>>
>
> At this time there is no code_change mechanism in Cowboy. Reloading a
> module works, modifying the protocol options with
> ranch:set_protocol_options can be used, but it doesn't change the running
> processes.
>
> --
> Lo?c Hoguin
> Erlang Cowboy
> Nine Nines
> http://ninenines.eu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130426/09f3ed34/attachment.html>

From yongboy at gmail.com  Fri Apr 26 08:11:56 2013
From: yongboy at gmail.com (yongboy)
Date: Fri, 26 Apr 2013 14:11:56 +0800
Subject: [99s-extend] cowboy how to ruduce the memory usage per long-hold
	connection
Message-ID: <CAN_mQBobPN0zdpqJ3WtGKJaRMNiutvurgJfncMCqM3qtUHTm1g@mail.gmail.com>

I have tested one long-hold webapp, when 512000 user connected, the app
used
6801M memory, 6801M*1024K / 512000 = 13.6K/Connection.

Does anyone give me some advice on how to reduce the memory usage per one
connection, thanks very much !

Here is the code snippet:

start(_Type, _Args) ->
        Dispatch = cowboy_router:compile([
            {'_', [{'_', htmlfile_handler, []}]}
        ]),
        cowboy:start_http(my_http_listener, 100,
            [{port, 8000}, {max_connections, infinity}],
            [{env, [{dispatch, Dispatch}]}]
        ),
        count_server:start(),
        htmlfilesimple_sup:start_link().

......

-module(htmlfile_handler).
-behaviour(cowboy_loop_handler).
-export([init/3, info/3, terminate/3]).
-define(HEARBEAT_TIMEOUT, 20*1000).
-record(status, {count=0}).

init(_Any, Req, State) ->
        NowCount = count_server:welcome(),
        io:format("online user ~p :))~n", [NowCount]),

        output_first(Req),
        Req2 = cowboy_req:compact(Req),
        {loop, Req2, State, hibernate}.

%% POST/Short Request
info(_Any, Req, State) ->
        {loop, Req, State, hibernate}.

output_first(Req) ->
        {ok, Reply} = cowboy_req:chunked_reply(200, [{<<"Content-Type">>,
<<"text/html; charset=utf-8">>},

{<<"Connection">>, <<"keep-alive">>}], Req),
        cowboy_req:chunk(<<"<html><body><script>var _ = function (msg) {
parent.s._(msg, document);
};</script>
">>,
                                                                Reply),
        cowboy_req:chunk(gen_output("1::"), Reply).

gen_output(String) ->
        DescList = io_lib:format("<script>_('~s');</script>", [String]),
        list_to_binary(DescList).

terminate(Reason, _Req, _State) ->
        NowCount = count_server:bye(),
        io:format("offline user ~p :(( ~n", [NowCount]).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130426/9d234e27/attachment.html>

From erlang at rambocoder.com  Fri Apr 26 15:11:53 2013
From: erlang at rambocoder.com (rambocoder)
Date: Fri, 26 Apr 2013 09:11:53 -0400
Subject: [99s-extend] cowboy how to ruduce the memory usage per
	long-hold connection
In-Reply-To: <CAN_mQBobPN0zdpqJ3WtGKJaRMNiutvurgJfncMCqM3qtUHTm1g@mail.gmail.com>
References: <CAN_mQBobPN0zdpqJ3WtGKJaRMNiutvurgJfncMCqM3qtUHTm1g@mail.gmail.com>
Message-ID: <CAJ0zLRPcYmH1OXeiw2aZHLtoqqdW=du0rhonF53xdCbMUmnCLw@mail.gmail.com>

Is 13.6K/connection considered a lot? Once you start doing SSL, each
connection will be about 80K, IMHO the most important factor for huge
ammount of COMET users is latency, which Cowboy and Erlang do great.

-rambocoder

On Fri, Apr 26, 2013 at 2:11 AM, yongboy <yongboy at gmail.com> wrote:

> I have tested one long-hold webapp, when 512000 user connected, the app
> used
> 6801M memory, 6801M*1024K / 512000 = 13.6K/Connection.
>
> Does anyone give me some advice on how to reduce the memory usage per one
> connection, thanks very much !
>
> Here is the code snippet:
>
> start(_Type, _Args) ->
>         Dispatch = cowboy_router:compile([
>             {'_', [{'_', htmlfile_handler, []}]}
>         ]),
>         cowboy:start_http(my_http_listener, 100,
>             [{port, 8000}, {max_connections, infinity}],
>             [{env, [{dispatch, Dispatch}]}]
>         ),
>         count_server:start(),
>         htmlfilesimple_sup:start_link().
>
> ......
>
> -module(htmlfile_handler).
> -behaviour(cowboy_loop_handler).
> -export([init/3, info/3, terminate/3]).
> -define(HEARBEAT_TIMEOUT, 20*1000).
> -record(status, {count=0}).
>
> init(_Any, Req, State) ->
>         NowCount = count_server:welcome(),
>         io:format("online user ~p :))~n", [NowCount]),
>
>         output_first(Req),
>         Req2 = cowboy_req:compact(Req),
>         {loop, Req2, State, hibernate}.
>
> %% POST/Short Request
> info(_Any, Req, State) ->
>         {loop, Req, State, hibernate}.
>
> output_first(Req) ->
>         {ok, Reply} = cowboy_req:chunked_reply(200, [{<<"Content-Type">>,
> <<"text/html; charset=utf-8">>},
>
> {<<"Connection">>, <<"keep-alive">>}], Req),
>         cowboy_req:chunk(<<"<html><body><script>var _ = function (msg) {
> parent.s._(msg, document);
> };</script>
> ">>,
>                                                                 Reply),
>         cowboy_req:chunk(gen_output("1::"), Reply).
>
> gen_output(String) ->
>         DescList = io_lib:format("<script>_('~s');</script>", [String]),
>         list_to_binary(DescList).
>
> terminate(Reason, _Req, _State) ->
>         NowCount = count_server:bye(),
>         io:format("offline user ~p :(( ~n", [NowCount]).
>
>
>
>
> _______________________________________________
> Extend mailing list
> Extend at lists.ninenines.eu
> http://lists.ninenines.eu:81/listinfo/extend
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130426/b1e8ae7a/attachment.html>

From essen at ninenines.eu  Fri Apr 26 17:21:32 2013
From: essen at ninenines.eu (=?ISO-8859-1?Q?Lo=EFc_Hoguin?=)
Date: Fri, 26 Apr 2013 17:21:32 +0200
Subject: [99s-extend] [ANN] Cowboy 0.8.4
Message-ID: <[email protected]>

Hello,

Cowboy 0.8.4 has been released!

This release features a tentatively stable API. This means that the 
complete API defined in this release should not change anymore. The API 
will be augmented with many features and functions of course, but 
existing code should not break anymore. Changes will only be considered 
if a feature causes bugs or too much confusion to the majority of users.

This release includes all the remaining changes that had to be done to 
REST, which is now no longer experimental and has documentation that you 
can find here:

   http://ninenines.eu/docs/en/cowboy/HEAD/guide/rest_handlers

Diagrams and their explanations will be added to the documentation in 
the next few days.

The full changelog for this release can be found here: 
https://github.com/extend/cowboy/commit/46b2ea0aaa7fe891bfdf3f8a0c47357393e72cf6

Enjoy!

-- 
Lo?c Hoguin
Erlang Cowboy
Nine Nines
http://ninenines.eu


From gdesouza at gmail.com  Tue Apr 30 20:59:21 2013
From: gdesouza at gmail.com (Gregory de Souza)
Date: Tue, 30 Apr 2013 14:59:21 -0400
Subject: [99s-extend] cowboy websocket and wamp
Message-ID: <CAAh+K4zu6f1CM1Dij7XsnUCLXXqaS3E6ZugABuaiST99Pz+KnA@mail.gmail.com>

Hi,
I'm new to the community and am exploring cowboy for a project.

Can anyone offer guidance/links on how to use cowboy's websocket support
with WAMP (http://wamp.ws/)?
The cowboy docs mention bullet <https://github.com/extend/bullet?source=cr> as
a convenient client/server lib (with an AJAX fallback) which is great, but
I'd like to use WAMP's RPC and PubSub so I'm unsure how to proceed.

Any tips would be appreciated!

Thanks in advance
-- 
Gregory | @gdesouza <http://twitter.com/gdesouza> | http://blog.gdesouza.me
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ninenines.eu/archives/extend/attachments/20130430/c86f8fdb/attachment.html>